Skip to content

Commit

Permalink
Merge pull request #52 from sstroemer/add-docstrings
Browse files Browse the repository at this point in the history
chore: new docstrings in `Utilities` module
  • Loading branch information
sstroemer authored Jan 10, 2025
2 parents 90235d4 + 82c91b3 commit 36ac0da
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/utils/modules/Utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,37 @@ function annuity(total::Real, lifetime::Real, rate::Real, fraction::Real)
@critical msg reason example
end

"""
timespan(model::JuMP.Model)::Float64
Calculate the total timespan (duration, time period, ...) of a model in hours.
# Arguments
- `model::JuMP.Model`: The model for which the timespan is to be calculated.
# Returns
`Float64`: The total timespan of the model in hours.
"""
function timespan(model::JuMP.Model)::Float64
return sum(s.weight for s in values(IESopt._iesopt_model(model).snapshots))
end

"""
yearspan(model::JuMP.Model)::Float64
Calculate the total timespan (duration, time period, ...) of a model in years. This assumes that a full year has a total
of 8760 hours.
# Arguments
- `model::JuMP.Model`: The model for which the timespan is to be calculated.
# Returns
`Float64`: The total timespan of the model in years.
"""
function yearspan(model::JuMP.Model)::Float64
return timespan(model) / 8760.0
end
Expand Down

0 comments on commit 36ac0da

Please sign in to comment.