@@ -1680,20 +1680,22 @@ get_instantiatedSubmodel(instantiatedModel, ID) = instantiatedModel.buildDict[ID
16801680
16811681
16821682"""
1683- index = new_x_segmented_variable!(
1684- instantiatedModel ::SimulationModel,
1685- x_name::String, der_x_name::String, startOrInit, x_unit::String="";
1686- nominal::Float64 = NaN, unbounded::Bool = false)::Int
1683+ startIndex = new_x_segmented_variable!(
1684+ partiallyInstantiatedModel ::SimulationModel,
1685+ x_name::String, der_x_name::String, startOrInit, x_unit::String="";
1686+ nominal::Float64 = NaN, unbounded::Bool = false)::Int
16871687
1688- Reserves storage location for a new x_segmented and der_x_segmented variable and returns
1689- the index (= x_segmented_startIndex) to access this storage location, in particular
1688+ Generate new states (`x_segmented` and `der_x_segmented` variables) and return the
1689+ `startIndex` of the variables in order that actual values can be inquired or copied from the
1690+ state `x` and state derivative `der(x)`vectors via [`get_x_startIndex_from_x_segmented_startIndex`](@ref).
1691+ `startOrInit` contain the `start` or `init` values of the newly generated `x_segmented` variable.
16901692
1691- - to copy state values from instantiatedModel.x_segmented[index:index+prod(dims(startOrInit))-1]
1692- into this storage location
1693- - to copy state derivative values of this storage location to
1694- instantiatedModel.der_x_segmented[index:index+prod(dims(startOrInit))-1]
1693+ Actual values of these new variables are stored in:
16951694
1696- Value startOrInit is the start/init value used during re-initialization of the new segment with initFullRestart!(..).
1695+ - `instantiatedModel.x_segmented[startIndex:startIndex+prod(dims(startOrInit))-1]`
1696+ - `instantiatedModel.der_x_segmented[startIndex:startIndex+prod(dims(startOrInit))-1]`
1697+
1698+ Value `startOrInit` is the start/init value used during re-initialization of the new segment with `initFullRestart!(..)`.
16971699"""
16981700function new_x_segmented_variable! (m:: SimulationModel{FloatType,TimeType} , x_name:: String , der_x_name:: String , startOrInit, x_unit:: String = " " ;
16991701 nominal:: Float64 = NaN , unbounded:: Bool = false ):: Int where {FloatType,TimeType}
@@ -1760,23 +1762,26 @@ end
17601762
17611763
17621764"""
1763- x_startIndex = get_x_startIndex_from_x_segmented_startIndex(instantiatedModel::SimulationModel, x_segmented_startIndex)
1765+ x_startIndex = get_x_startIndex_from_x_segmented_startIndex(
1766+ instantiatedModel::SimulationModel, x_segmented_startIndex)
17641767
1765- Return the startindex of an x_segmented state with respect to the x -vector,
1766- given the startIndex with respect to the x_segmented vector
1767- (x_segmented_startIndex is the return value of new_x_segmented_variable!(..)).
1768+ Return the startindex of an ` x_segmented` state with respect to the `x` -vector,
1769+ given the startIndex with respect to the ` x_segmented` vector
1770+ (` x_segmented_startIndex` is the return value of ` new_x_segmented_variable!(..)` ).
17681771"""
17691772get_x_startIndex_from_x_segmented_startIndex (m:: SimulationModel , x_segmented_startIndex:: Int ) = m. equationInfo. nxInvariant + x_segmented_startIndex
17701773
17711774
17721775"""
1773- index = new_w_segmented_variable!(partiallyInstantiatedModel::SimulationModel, name::String,
1774- w_segmented_default, unit::String="")::Int
1776+ index = new_w_segmented_variable!(
1777+ partiallyInstantiatedModel::SimulationModel, name::String,
1778+ w_segmented_default, unit::String="")::Int
17751779
1776- Reserve storage location for a new w_segmented variable. The returned `index` is
1777- used to store the w_segmented value at communication points in the result data structure.
1780+ Generate new local variable (`w_segmented` variable) and return the `index` of the variable
1781+ in order that actual values can be inquired or copied from the result data structure.
1782+ New values of `w_segmented` variables need only to be computed at communication points.
17781783Value w_segmented_default is stored as default value and defines type and (fixed) size of the variable
1779- in this segment.
1784+ in this simulation segment.
17801785"""
17811786function new_w_segmented_variable! (m:: SimulationModel , name:: String , w_segmented_default, unit:: String = " " ):: Int
17821787 result = m. result
@@ -1810,9 +1815,10 @@ end
18101815
18111816
18121817"""
1813- new_alias_segmented_variable!(partiallyInstantiatedModel, name, aliasName, aliasNegate=false)
1818+ new_alias_segmented_variable!(partiallyInstantiatedModel::SimulationModel,
1819+ name, aliasName, aliasNegate=false)
18141820
1815- Define new alias segmented variable.
1821+ Define new alias variable.
18161822"""
18171823function new_alias_segmented_variable! (m:: SimulationModel , name:: String , aliasName:: String , aliasNegate:: Bool = false ):: Int
18181824 result = m. result
@@ -1832,8 +1838,8 @@ end
18321838"""
18331839 startIndex = new_z_segmented_variable!(instantiatedModel, nz)
18341840
1835- Reserve storage location for nz new segmented zero crossing function and return the startIndex to
1836- copy it in the vectors of zero crossings
1841+ Generate `nz` new zero crossing variables and return the startIndex to of the variables
1842+ in order that actual values can be copied into the vector of zero crossings.
18371843"""
18381844function new_z_segmented_variable! (m:: SimulationModel{F,TimeType} , nz:: Int ):: Int where {F,TimeType}
18391845 eh = m. eventHandler
@@ -1850,58 +1856,60 @@ end
18501856
18511857
18521858"""
1853- value = Modia.get_scalar_x_segmented_value (instantiatedModel, startIndex)
1859+ value = Modia.copy_scalar_x_segmented_value_from_state (instantiatedModel, startIndex)
18541860
1855- Return scalar segmented state value from instantiatedModel given `startIndex`
1861+ Return value of scalar x_segmented variable from state vector `x` by providing its `startIndex`
18561862(returned from `new_x_segmented_variable!(..)`).
18571863"""
1858- get_scalar_x_segmented_value (m:: SimulationModel , startIndex:: Int ) = m. x_segmented[startIndex]
1864+ copy_scalar_x_segmented_value_from_state (m:: SimulationModel , startIndex:: Int ) = m. x_segmented[startIndex]
18591865
18601866
18611867"""
1862- value = Modia.get_SVector3_x_segmented_value (instantiatedModel, startIndex)
1868+ value = Modia.copy_SVector3_x_segmented_value_from_state (instantiatedModel, startIndex)
18631869
1864- Return SVector{3,FloatType}(..) segmented state value from instantiatedModel given `startIndex`
1870+ Return value of ` SVector{3,FloatType}` x_segmented variable from state vector `x` by providing its `startIndex`
18651871(returned from `new_x_segmented_variable!(..)`).
18661872"""
1867- @inline get_SVector3_x_segmented_value (m:: SimulationModel{FloatType,TimeType} , startIndex:: Int ) where {FloatType,TimeType} = begin
1873+ @inline copy_SVector3_x_segmented_value_from_state (m:: SimulationModel{FloatType,TimeType} , startIndex:: Int ) where {FloatType,TimeType} = begin
18681874 x_segmented = m. x_segmented
18691875 return SVector {3,FloatType} (x_segmented[startIndex], x_segmented[startIndex+ 1 ], x_segmented[startIndex+ 2 ])
18701876end
18711877
18721878"""
1873- Modia.get_Vector_x_segmented_value! (instantiatedModel::SimulationModel, startIndex, xi::Vector{FloatType})::Nothing
1879+ Modia.copy_Vector_x_segmented_value_from_state (instantiatedModel::SimulationModel, startIndex, xi::Vector{FloatType})::Nothing
18741880
1875- Copy state from `instantiatedModel` at index `startIndex` into pre-allocated vector `xi`.
1881+ Return value of `Vector{FloatType}` x_segmented variable from state vector `x` by providing its `startIndex`
1882+ (returned from `new_x_segmented_variable!(..)`) and copying it into the pre-allocated vector `xi`.
18761883"""
1877- @inline function get_Vector_x_segmented_value! (m:: SimulationModel{FloatType,TimeType} , startIndex:: Int , xi:: Vector{FloatType} ):: Nothing where {FloatType,TimeType}
1884+ @inline function copy_Vector_x_segmented_value_from_state (m:: SimulationModel{FloatType,TimeType} , startIndex:: Int , xi:: Vector{FloatType} ):: Nothing where {FloatType,TimeType}
18781885 copyto! (xi, 1 , m. x_segmented, startIndex, length (xi))
18791886 return nothing
18801887end
18811888
18821889
18831890"""
1884- Modia.add_der_x_segmented_value! (instantiatedModel, startIndex, der_x_segmented_value::[FloatType|Vector{FloatType}])
1891+ Modia.copy_der_x_segmented_value_to_state (instantiatedModel, startIndex, der_x_segmented_value::[FloatType|Vector{FloatType}])
18851892
1886- Copy scalar or array segmented state derivative value `der_x_segmented_value` into `instantiatedModel` starting at index `startIndex`
1887- (returned from `new_x_segmented_variable!(..)`).
1893+ Copy `der_x_segmented_value` to state derivative vector `der(x)` by providing its `startIndex`
1894+ (returned from `new_x_segmented_variable!(..)`) and copying it into the pre-allocated vector `der_x_segmented_value` .
18881895"""
1889- @inline function add_der_x_segmented_value! (m:: SimulationModel{FloatType,TimeType} , startIndex:: Int , der_x_segmented_value:: FloatType ):: Nothing where {FloatType,TimeType}
1896+ @inline function copy_der_x_segmented_value_to_state (m:: SimulationModel{FloatType,TimeType} , startIndex:: Int , der_x_segmented_value:: FloatType ):: Nothing where {FloatType,TimeType}
18901897 m. der_x_segmented[startIndex] = der_x_segmented_value
18911898 return nothing
18921899end
1893- @inline function add_der_x_segmented_value! (m:: SimulationModel{FloatType,TimeType} , startIndex:: Int , der_x_segmented_value:: Vector{FloatType} ):: Nothing where {FloatType,TimeType}
1900+ @inline function copy_der_x_segmented_value_to_state (m:: SimulationModel{FloatType,TimeType} , startIndex:: Int , der_x_segmented_value:: Vector{FloatType} ):: Nothing where {FloatType,TimeType}
18941901 copyto! (m. der_x_segmented, startIndex, der_x_segmented_value, 1 , length (der_x_segmented_value))
18951902 return nothing
18961903end
18971904
18981905
18991906"""
1900- Modia.add_w_segmented_value! (instantiatedModel::SimulationModel, index::Int, w_segmented_value)::Nothing
1907+ Modia.copy_w_segmented_value_to_result (instantiatedModel::SimulationModel, index::Int, w_segmented_value)::Nothing
19011908
1902- Store deepcopy(w_segmented_value) at index in instantiatedModel.
1909+ Copy value of local variable (`w-segmented`) to result by providing its `index`
1910+ (returned from `new_w_segmented_variable!`),
19031911"""
1904- @inline function add_w_segmented_value! (m:: SimulationModel , index:: Int , w_segmented_value):: Nothing
1912+ @inline function copy_w_segmented_value_to_result (m:: SimulationModel , index:: Int , w_segmented_value):: Nothing
19051913 w_segmented_temp = m. result. w_segmented_temp
19061914 @assert (typeof (w_segmented_value) == typeof (w_segmented_temp[index]))
19071915 @assert (size ( w_segmented_value) == size ( w_segmented_temp[index]))
0 commit comments