Skip to content

Commit

Permalink
We use the GeometricRegion to recover the correct size of the 'ROLE_S…
Browse files Browse the repository at this point in the history
…ize' StructureMappingParameter
  • Loading branch information
danv61 committed Mar 4, 2024
1 parent 0423d15 commit 1030e66
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.beans.PropertyVetoException;
import java.util.*;

import cbit.vcell.geometry.surface.GeometricRegion;
import org.vcell.model.rbm.ComponentStateDefinition;
import org.vcell.model.rbm.ComponentStatePattern;
import org.vcell.model.rbm.MolecularComponent;
Expand Down Expand Up @@ -338,15 +339,21 @@ protected void refreshMathDescription() throws MappingException, MatrixException
for (int i=0;i<structureMappings.length;i++){
StructureMapping sm = structureMappings[i];
StructureMapping.StructureMappingParameter parm = sm.getParameterFromRole(StructureMapping.ROLE_Size);
if(parm.getExpression() != null)
if(parm.getExpression() != null) // this is the default 50,000 um3 which don't make any sense for Langevin; we don't use it!!!
{
try {
double value = parm.getExpression().evaluateConstant();
varHash.addVariable(new Constant(getMathSymbol(parm,sm.getGeometryClass()),new Expression(value)));
}catch (ExpressionException e){
//varHash.addVariable(new Function(getMathSymbol0(parm,sm),getIdentifierSubstitutions(parm.getExpression(),parm.getUnitDefinition(),sm)));
// instead, we use the size of the geometric region
GeometricRegion[] grArray = simContext.getGeometry().getGeometrySurfaceDescription().getGeometricRegions(sm.getGeometryClass());
if(grArray.length != 1) {
throw new RuntimeException("Expecting only one region for GeometryClass '" + sm.getGeometryClass().getName() + "', found: " + grArray.length);
}
GeometricRegion gr = grArray[0];
double value2 = gr.getSize();
varHash.addVariable(new Constant(getMathSymbol(parm, sm.getGeometryClass()), new Expression(value2)));

}catch (Exception e) {
e.printStackTrace(System.out);
throw new MappingException("Size of structure:"+sm.getNameScope().getName()+" cannot be evaluated as constant.");
throw new MappingException("Size of structure:"+sm.getNameScope().getName()+" cannot be evaluated.");
}
}
}
Expand Down

0 comments on commit 1030e66

Please sign in to comment.