Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3196,6 +3196,7 @@ private void openAfterChecking(VCDocumentInfo documentInfo, final TopLevelWindow
boolean bRuleBased = true;
SimulationContext ruleBasedSimContext = bioModel.addNewSimulationContext("temp NFSim app",
SimulationContext.Application.RULE_BASED_STOCHASTIC);
ruleBasedSimContext.setUsingConcentration(bngUnitSystem.isConcentration(), false);
List<SimulationContext> appList = new ArrayList<SimulationContext>();
appList.add(ruleBasedSimContext);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2984,8 +2984,11 @@ public void setUsingMassConservationModelReduction(boolean bMassConservationMode
}

public void setUsingConcentration(boolean bUseConcentration, boolean bTransformIfNeeded) throws PropertyVetoException, MappingException, MatrixException, ModelException, MathException, ExpressionException /*throws MappingException, PropertyVetoException*/{
if(applicationType == Application.NETWORK_STOCHASTIC || applicationType == Application.RULE_BASED_STOCHASTIC ||
applicationType == Application.SPRINGSALAD) {
if (applicationType == Application.NETWORK_STOCHASTIC ||
applicationType == Application.RULE_BASED_STOCHASTIC ||
applicationType == Application.SPRINGSALAD ||
(applicationType == Application.NETWORK_DETERMINISTIC && getGeometry().getDimension() == 0)
) {
boolean oldValue = bConcentration;
if(bUseConcentration != oldValue && bTransformIfNeeded){
MathMapping mathMapping = createNewMathMapping();
Expand Down
17 changes: 8 additions & 9 deletions vcell-core/src/main/java/org/vcell/model/rbm/RbmUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,17 @@ public Object visit(ASTSeedSpecies node, Object data) {
SpeciesContext speciesContext = model.createSpeciesContext(structure, seedSpecies.getSpeciesPattern());
for(SimulationContext application : appList) {
SpeciesContextSpec scs = application.getReactionContext().getSpeciesContextSpec(speciesContext);
if (bngUnitSystem.isConcentration() && application.isUsingConcentration()){
if (bngUnitSystem.isConcentration() != application.isUsingConcentration()) {
throw new RuntimeException("BNGL model unit system is " + (bngUnitSystem.isConcentration() ? "concentration" : "count") +
" but application is using " + (application.isUsingConcentration() ? "concentration" : "count") +
". Please change the application unit system to match the model unit system.");
}
if (application.isUsingConcentration()){
scs.getParameter(SpeciesContextSpec.ROLE_InitialConcentration).setExpression(exp);
}else if (!bngUnitSystem.isConcentration() && !application.isUsingConcentration()){
}else{
scs.getParameter(SpeciesContextSpec.ROLE_InitialCount).setExpression(exp);
}else if (!bngUnitSystem.isConcentration() && application.isUsingConcentration()){
Expression covertedConcentration = scs.convertParticlesToConcentration(exp);
scs.getParameter(SpeciesContextSpec.ROLE_InitialConcentration).setExpression(covertedConcentration);
}else if (bngUnitSystem.isConcentration() && !application.isUsingConcentration()){
Expression covertedAmount = scs.convertConcentrationToParticles(exp);
scs.getParameter(SpeciesContextSpec.ROLE_InitialCount).setExpression(covertedAmount);
}
scs.setConstant(node.isClamped());
scs.setClamped(node.isClamped());
}
} catch (Exception ex) {
throw new RuntimeException(ex.getMessage(), ex);
Expand Down