Skip to content

Commit 342331a

Browse files
authored
Fixes #2769 Allow override of initial condition values when creating (#2770)
1 parent 6182b22 commit 342331a

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

src/OSPSuite.Core/Domain/Services/InitialConditionsCreator.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,21 @@ public interface IInitialConditionsCreator : IEmptyStartValueCreator<InitialCond
1414
InitialConditionsBuildingBlock CreateFrom(SpatialStructure spatialStructure, IReadOnlyList<MoleculeBuilder> molecules);
1515

1616
/// <summary>
17-
/// Creates an initial condition
17+
/// Creates an initial condition with mandatory <paramref name="containerPath" />, <paramref name="moleculeName" /> and
18+
/// <paramref name="dimension" />. The other parameters are optional and will be set to default values if not supplied.
19+
/// default <paramref name="displayUnit"/> is the default unit of the <paramref name="dimension"/>
20+
/// The initial condition will not be added to any building block, this is the responsibility of the caller.
1821
/// </summary>
19-
/// <param name="containerPath">The container path for the molecule</param>
20-
/// <param name="moleculeName">The name of the molecule</param>
21-
/// <param name="dimension">The dimension of the initial condition</param>
22-
/// <param name="displayUnit">
23-
/// The display unit of the start value. If not set, the default unit of the
24-
/// <paramref name="dimension" />will be used
25-
/// </param>
26-
/// <param name="valueOrigin">The value origin for the value</param>
2722
/// <returns>an InitialCondition object</returns>
28-
InitialCondition CreateInitialCondition(ObjectPath containerPath, string moleculeName, IDimension dimension, Unit displayUnit = null, ValueOrigin valueOrigin = null);
23+
InitialCondition CreateInitialCondition(ObjectPath containerPath,
24+
string moleculeName,
25+
IDimension dimension,
26+
Unit displayUnit = null,
27+
ValueOrigin valueOrigin = null,
28+
bool isPresent = true,
29+
double valueInBaseUnit = 0,
30+
double scaleDivisor = Constants.DEFAULT_SCALE_DIVISOR,
31+
bool negativeValuesAllowed = false);
2932

3033
/// <summary>
3134
/// Creates a new initial conditions for the <paramref name="molecule" /> in the <paramref name="containers" /> and adds
@@ -130,18 +133,27 @@ private void setInitialConditionFormula(IFormula formula, InitialCondition initi
130133
initialCondition.Formula = createFormulaFrom(formula);
131134
}
132135

133-
public InitialCondition CreateInitialCondition(ObjectPath containerPath, string moleculeName, IDimension dimension, Unit displayUnit = null, ValueOrigin valueOrigin = null)
136+
public InitialCondition CreateInitialCondition(ObjectPath containerPath,
137+
string moleculeName,
138+
IDimension dimension,
139+
Unit displayUnit = null,
140+
ValueOrigin valueOrigin = null,
141+
bool isPresent = true,
142+
double valueInBaseUnit = 0,
143+
double scaleDivisor = Constants.DEFAULT_SCALE_DIVISOR,
144+
bool negativeValuesAllowed = false)
134145
{
135146
var initialCondition = new InitialCondition
136147
{
137148
Id = _idGenerator.NewId(),
138-
IsPresent = true,
149+
IsPresent = isPresent,
139150
ContainerPath = containerPath,
140151
Name = moleculeName,
141152
Dimension = dimension,
142153
DisplayUnit = displayUnit ?? dimension.DefaultUnit,
143-
NegativeValuesAllowed = false,
144-
Value = 0
154+
NegativeValuesAllowed = negativeValuesAllowed,
155+
Value = valueInBaseUnit,
156+
ScaleDivisor = scaleDivisor
145157
};
146158

147159
initialCondition.ValueOrigin.UpdateAllFrom(valueOrigin);

0 commit comments

Comments
 (0)