use of cbit.vcell.mapping.AbstractMathMapping.MathMappingParameter in project vcell by virtualcell.
the class StructureAnalyzer method refreshTotalDependancies.
/**
* This method was created by a SmartGuide.
* @param b cbit.vcell.math.Matrix
* @param vars java.lang.String[]
*/
private void refreshTotalDependancies() throws Exception {
//
for (int v = 0; v < speciesContextMappings.length; v++) {
speciesContextMappings[v].setDependencyExpression(null);
}
if (totalNullSpaceMatrix == null) {
// System.out.println("the matrix has full rank, there are no dependencies");
return;
}
if (speciesContextMappings.length != totalNullSpaceMatrix.getNumCols()) {
throw new Exception("varName array not same dimension as b matrix");
}
StructureAnalyzer.Dependency[] dependencies = refreshTotalDependancies(totalNullSpaceMatrix, speciesContextMappings, mathMapping, false);
VCUnitDefinition totalMassUnit = null;
boolean bIsSpatial = mathMapping.getSimulationContext().getGeometry().getDimension() > 0;
ModelUnitSystem modelUnitSystem = mathMapping.getSimulationContext().getModel().getUnitSystem();
if (this instanceof VolumeStructureAnalyzer) {
if (!bIsSpatial) {
// VCUnitDefinition.UNIT_umol_um3_per_L; -> VCell vol substance unit
totalMassUnit = modelUnitSystem.getVolumeSubstanceUnit();
} else {
// VCUnitDefinition.UNIT_uM;
totalMassUnit = modelUnitSystem.getVolumeConcentrationUnit();
}
} else if (this instanceof MembraneStructureAnalyzer) {
if (!bIsSpatial) {
// VCUnitDefinition.UNIT_molecules;
totalMassUnit = modelUnitSystem.getMembraneSubstanceUnit();
} else {
// VCUnitDefinition.UNIT_molecules_per_um2;
totalMassUnit = modelUnitSystem.getMembraneConcentrationUnit();
}
}
for (int i = 0; i < dependencies.length; i++) {
String constantName = dependencies[i].invariantSymbolName;
Expression constantExp = dependencies[i].conservedMoietyExpression;
SpeciesContextMapping firstSCM = dependencies[i].speciesContextMapping;
Expression exp = dependencies[i].dependencyExpression;
//
// store totalMass parameter (e.g. K_xyz_total = xyz_init + wzy_init)
//
GeometryClass geometryClass = mathMapping.getSimulationContext().getGeometryContext().getStructureMapping(firstSCM.getSpeciesContext().getStructure()).getGeometryClass();
MathMappingParameter totalMassParameter = mathMapping.addMathMappingParameter(constantName, constantExp.flatten(), DiffEquMathMapping.PARAMETER_ROLE_TOTALMASS, totalMassUnit, geometryClass);
//
// store dependency parameter (e.g. xyz = K_xyz_total - wzy)
//
exp.bindExpression(mathMapping);
firstSCM.setDependencyExpression(exp);
}
}
Aggregations