use of cbit.vcell.model.Model.StructureTopology in project vcell by virtualcell.
the class ElectricalStimulusPanel method newStimulus.
/**
* Comment
*/
private void newStimulus() {
try {
SimulationContext simContext = getSimulationContext();
if (simContext == null) {
return;
}
//
// When the voltage and current clamp radio buttons is deselected within the same simulation context (application),
// display a warning saying that the present clamp settings will be lost (not applicable when the 'no clamp'
// radiobutton is deselected.
//
ElectricalStimulus currElectricalStimulus = null;
if (simContext.getElectricalStimuli() != null && simContext.getElectricalStimuli().length > 0) {
currElectricalStimulus = simContext.getElectricalStimuli()[0];
}
//
// ignore selection if already selected
// warn upon deselect if about to loose edits
//
Clamp selectedClamp = (Clamp) clampComboBox.getSelectedItem();
if (currElectricalStimulus instanceof VoltageClampStimulus) {
if (selectedClamp == Clamp.Voltage_Clamp) {
return;
}
String response = PopupGenerator.showWarningDialog(this, "warning: the present voltage clamp settings will be lost", new String[] { UserMessage.OPTION_CONTINUE, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_CONTINUE);
if (response == null || response.equals(UserMessage.OPTION_CANCEL)) {
// revert back to Voltage Clamp
clampComboBox.setSelectedItem(Clamp.Voltage_Clamp);
return;
}
}
if (currElectricalStimulus instanceof TotalCurrentClampStimulus) {
if (selectedClamp == Clamp.Total_Current_Clamp) {
return;
}
String response = PopupGenerator.showWarningDialog(this, "warning: the present current clamp settings will be lost", new String[] { UserMessage.OPTION_CONTINUE, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_CONTINUE);
if (response == null || response.equals(UserMessage.OPTION_CANCEL)) {
// revert back to Current Clamp
clampComboBox.setSelectedItem(Clamp.Total_Current_Clamp);
return;
}
}
if (currElectricalStimulus instanceof CurrentDensityClampStimulus) {
if (selectedClamp == Clamp.Current_Density_Clamp) {
return;
}
String response = PopupGenerator.showWarningDialog(this, "warning: the present current clamp settings will be lost", new String[] { UserMessage.OPTION_CONTINUE, UserMessage.OPTION_CANCEL }, UserMessage.OPTION_CONTINUE);
if (response == null || response.equals(UserMessage.OPTION_CANCEL)) {
// revert back to Current Clamp
clampComboBox.setSelectedItem(Clamp.Current_Density_Clamp);
return;
}
}
if (currElectricalStimulus == null && selectedClamp == Clamp.No_Clamp) {
return;
}
StructureTopology structTopology = getSimulationContext().getModel().getStructureTopology();
Structure[] structures = getSimulationContext().getModel().getStructures();
ArrayList<Feature> features = new ArrayList<Feature>();
for (Structure structure : structures) {
if (structure instanceof Feature) {
features.add((Feature) structure);
}
}
if (features.size() < 2) {
PopupGenerator.showErrorDialog(this, "error: electrodes must be placed in distinct volumetric structures, found " + features.size() + " volumetric structures in model");
return;
}
Feature groundFeature = features.get(0);
Feature clampedFeature = features.get(1);
//
if (selectedClamp == Clamp.Total_Current_Clamp) {
if (simContext.getElectricalStimuli().length == 0 || !(simContext.getElectricalStimuli()[0] instanceof TotalCurrentClampStimulus)) {
Electrode probeElectrode = new Electrode(clampedFeature, new Coordinate(0, 0, 0));
TotalCurrentClampStimulus ccStimulus = new TotalCurrentClampStimulus(probeElectrode, "ccElectrode", new Expression(0.0), simContext);
System.out.println(" Geo's dim = " + simContext.getGeometry().getDimension());
simContext.setElectricalStimuli(new ElectricalStimulus[] { ccStimulus });
simContext.setGroundElectrode(new Electrode(groundFeature, new Coordinate(0, 0, 0)));
}
}
//
if (selectedClamp == Clamp.Current_Density_Clamp) {
if (simContext.getElectricalStimuli().length == 0 || !(simContext.getElectricalStimuli()[0] instanceof CurrentDensityClampStimulus)) {
Electrode probeElectrode = new Electrode(clampedFeature, new Coordinate(0, 0, 0));
CurrentDensityClampStimulus ccStimulus = new CurrentDensityClampStimulus(probeElectrode, "ccElectrode", new Expression(0.0), simContext);
System.out.println(" Geo's dim = " + simContext.getGeometry().getDimension());
simContext.setElectricalStimuli(new ElectricalStimulus[] { ccStimulus });
simContext.setGroundElectrode(new Electrode(groundFeature, new Coordinate(0, 0, 0)));
}
}
//
if (selectedClamp == Clamp.No_Clamp) {
if (simContext.getElectricalStimuli().length > 0) {
simContext.setElectricalStimuli(new ElectricalStimulus[0]);
}
}
//
if (selectedClamp == Clamp.Voltage_Clamp) {
if (simContext.getElectricalStimuli().length == 0 || !(simContext.getElectricalStimuli()[0] instanceof VoltageClampStimulus)) {
Electrode probeElectrode = new Electrode(clampedFeature, new Coordinate(0, 0, 0));
VoltageClampStimulus vcStimulus = new VoltageClampStimulus(probeElectrode, "vcElectrode", new Expression(0.0), simContext);
System.out.println(" Geo's dim = " + simContext.getGeometry().getDimension());
simContext.setElectricalStimuli(new ElectricalStimulus[] { vcStimulus });
simContext.setGroundElectrode(new Electrode(groundFeature, new Coordinate(0, 0, 0)));
}
}
} catch (java.beans.PropertyVetoException e) {
PopupGenerator.showErrorDialog(this, "Error setting electrical stimulus: " + e.getMessage());
}
}
use of cbit.vcell.model.Model.StructureTopology in project vcell by virtualcell.
the class CurrentClampElectricalDevice method initializeParameters.
private void initializeParameters() throws ExpressionException {
ElectricalDevice.ElectricalDeviceParameter[] parameters = new ElectricalDevice.ElectricalDeviceParameter[3];
//
// set the transmembrane current (total current, if necessary derive it from the current density).
//
ElectricalDeviceParameter transMembraneCurrent = null;
ModelUnitSystem modelUnitSystem = mathMapping.getSimulationContext().getModel().getUnitSystem();
VCUnitDefinition currentUnit = modelUnitSystem.getCurrentUnit();
if (currentClampStimulus instanceof TotalCurrentClampStimulus) {
TotalCurrentClampStimulus stimulus = (TotalCurrentClampStimulus) currentClampStimulus;
LocalParameter currentParameter = stimulus.getCurrentParameter();
transMembraneCurrent = new ElectricalDeviceParameter(DefaultNames[ROLE_TransmembraneCurrent], new Expression(currentParameter.getExpression()), ROLE_TransmembraneCurrent, currentUnit);
} else if (currentClampStimulus instanceof CurrentDensityClampStimulus) {
CurrentDensityClampStimulus stimulus = (CurrentDensityClampStimulus) currentClampStimulus;
LocalParameter currentDensityParameter = stimulus.getCurrentDensityParameter();
//
// here we have to determine the expression for current (from current density).
//
Feature feature1 = currentClampStimulus.getElectrode().getFeature();
Feature feature2 = mathMapping.getSimulationContext().getGroundElectrode().getFeature();
Membrane membrane = null;
StructureTopology structTopology = mathMapping.getSimulationContext().getModel().getStructureTopology();
if (structTopology.getParentStructure(feature1) != null && structTopology.getOutsideFeature((Membrane) structTopology.getParentStructure(feature1)) == feature2) {
membrane = ((Membrane) structTopology.getParentStructure(feature1));
} else if (structTopology.getParentStructure(feature2) != null && structTopology.getOutsideFeature((Membrane) structTopology.getParentStructure(feature2)) == feature1) {
membrane = ((Membrane) structTopology.getParentStructure(feature2));
}
if (membrane == null) {
throw new RuntimeException("current clamp based on current density crosses multiple membranes, unable to " + "determine single membrane to convert current density into current in Application '" + mathMapping.getSimulationContext().getName() + "'.");
}
MembraneMapping membraneMapping = (MembraneMapping) mathMapping.getSimulationContext().getGeometryContext().getStructureMapping(membrane);
StructureMappingParameter sizeParameter = membraneMapping.getSizeParameter();
Expression area = null;
if (mathMapping.getSimulationContext().getGeometry().getDimension() == 0 && (sizeParameter.getExpression() == null || sizeParameter.getExpression().isZero())) {
area = membraneMapping.getNullSizeParameterValue();
} else {
area = new Expression(sizeParameter, mathMapping.getNameScope());
}
transMembraneCurrent = new ElectricalDeviceParameter(DefaultNames[ROLE_TransmembraneCurrent], Expression.mult(new Expression(currentDensityParameter.getExpression()), area), ROLE_TransmembraneCurrent, currentUnit);
} else {
throw new RuntimeException("unexpected current clamp stimulus type : " + currentClampStimulus.getClass().getName());
}
ElectricalDeviceParameter totalCurrent = new ElectricalDeviceParameter(DefaultNames[ROLE_TotalCurrent], new Expression(transMembraneCurrent, getNameScope()), ROLE_TotalCurrent, currentUnit);
ElectricalDeviceParameter voltage = new ElectricalDeviceParameter(DefaultNames[ROLE_Voltage], null, ROLE_Voltage, modelUnitSystem.getVoltageUnit());
parameters[0] = totalCurrent;
parameters[1] = transMembraneCurrent;
parameters[2] = voltage;
//
// add any user-defined parameters
//
LocalParameter[] stimulusParameters = currentClampStimulus.getLocalParameters();
for (int i = 0; stimulusParameters != null && i < stimulusParameters.length; i++) {
if (stimulusParameters[i].getRole() == ElectricalStimulus.ElectricalStimulusParameterType.UserDefined) {
ElectricalDeviceParameter newParam = new ElectricalDeviceParameter(stimulusParameters[i].getName(), new Expression(stimulusParameters[i].getExpression()), ROLE_UserDefined, stimulusParameters[i].getUnitDefinition());
parameters = (ElectricalDeviceParameter[]) BeanUtils.addElement(parameters, newParam);
}
}
setParameters(parameters);
}
use of cbit.vcell.model.Model.StructureTopology in project vcell by virtualcell.
the class CurrentClampElectricalDevice method initializeParameters.
private void initializeParameters() throws ExpressionException {
ElectricalDevice.ElectricalDeviceParameter[] parameters = new ElectricalDevice.ElectricalDeviceParameter[3];
//
// set the transmembrane current (total current, if necessary derive it from the current density).
//
ElectricalDeviceParameter transMembraneCurrent = null;
ModelUnitSystem modelUnitSystem = mathMapping_4_8.getSimulationContext().getModel().getUnitSystem();
VCUnitDefinition currentUnit = modelUnitSystem.getCurrentUnit();
if (currentClampStimulus instanceof TotalCurrentClampStimulus) {
TotalCurrentClampStimulus stimulus = (TotalCurrentClampStimulus) currentClampStimulus;
LocalParameter currentParameter = stimulus.getCurrentParameter();
transMembraneCurrent = new ElectricalDeviceParameter(DefaultNames[ROLE_TransmembraneCurrent], new Expression(currentParameter.getExpression()), ROLE_TransmembraneCurrent, currentUnit);
} else if (currentClampStimulus instanceof CurrentDensityClampStimulus) {
CurrentDensityClampStimulus stimulus = (CurrentDensityClampStimulus) currentClampStimulus;
LocalParameter currentDensityParameter = stimulus.getCurrentDensityParameter();
//
// here we have to determine the expression for current (from current density).
//
Feature feature1 = currentClampStimulus.getElectrode().getFeature();
Feature feature2 = mathMapping_4_8.getSimulationContext().getGroundElectrode().getFeature();
Membrane membrane = null;
StructureTopology structTopology = mathMapping_4_8.getSimulationContext().getModel().getStructureTopology();
if (structTopology.getParentStructure(feature1) != null && structTopology.getOutsideFeature((Membrane) structTopology.getParentStructure(feature1)) == feature2) {
membrane = ((Membrane) structTopology.getParentStructure(feature1));
} else if (structTopology.getParentStructure(feature2) != null && structTopology.getOutsideFeature((Membrane) structTopology.getParentStructure(feature2)) == feature1) {
membrane = ((Membrane) structTopology.getParentStructure(feature2));
}
if (membrane == null) {
throw new RuntimeException("current clamp based on current density crosses multiple membranes, unable to " + "determine single membrane to convert current density into current in Application '" + mathMapping_4_8.getSimulationContext().getName() + "'.");
}
MembraneMapping membraneMapping = (MembraneMapping) mathMapping_4_8.getSimulationContext().getGeometryContext().getStructureMapping(membrane);
StructureMappingParameter sizeParameter = membraneMapping.getSizeParameter();
Expression area = null;
if (mathMapping_4_8.getSimulationContext().getGeometry().getDimension() == 0 && (sizeParameter.getExpression() == null || sizeParameter.getExpression().isZero())) {
area = membraneMapping.getNullSizeParameterValue();
} else {
area = new Expression(sizeParameter, mathMapping_4_8.getNameScope());
}
transMembraneCurrent = new ElectricalDeviceParameter(DefaultNames[ROLE_TransmembraneCurrent], Expression.mult(new Expression(currentDensityParameter.getExpression()), area), ROLE_TransmembraneCurrent, currentUnit);
} else {
throw new RuntimeException("unexpected current clamp stimulus type : " + currentClampStimulus.getClass().getName());
}
ElectricalDeviceParameter totalCurrent = new ElectricalDeviceParameter(DefaultNames[ROLE_TotalCurrent], new Expression(transMembraneCurrent, getNameScope()), ROLE_TotalCurrent, currentUnit);
ElectricalDeviceParameter voltage = new ElectricalDeviceParameter(DefaultNames[ROLE_Voltage], null, ROLE_Voltage, modelUnitSystem.getVoltageUnit());
parameters[0] = totalCurrent;
parameters[1] = transMembraneCurrent;
parameters[2] = voltage;
//
// add any user-defined parameters
//
LocalParameter[] stimulusParameters = currentClampStimulus.getLocalParameters();
for (int i = 0; stimulusParameters != null && i < stimulusParameters.length; i++) {
if (stimulusParameters[i].getRole() == ElectricalStimulus.ElectricalStimulusParameterType.UserDefined) {
ElectricalDeviceParameter newParam = new ElectricalDeviceParameter(stimulusParameters[i].getName(), new Expression(stimulusParameters[i].getExpression()), ROLE_UserDefined, stimulusParameters[i].getUnitDefinition());
parameters = (ElectricalDeviceParameter[]) BeanUtils.addElement(parameters, newParam);
}
}
setParameters(parameters);
}
use of cbit.vcell.model.Model.StructureTopology in project vcell by virtualcell.
the class MathMapping_4_8 method getResolved.
boolean getResolved(StructureMapping structureMapping) {
if (simContext == null || structureMapping.getStructure() == null) {
throw new RuntimeException("failed to process getResolved()");
}
if (structureMapping.getGeometryClass() == null) {
return false;
}
StructureTopology structureTopology = simContext.getModel().getStructureTopology();
Structure parentStructure = structureTopology.getParentStructure(structureMapping.getStructure());
if (parentStructure != null) {
StructureMapping outsideSM = simContext.getGeometryContext().getStructureMapping(parentStructure);
if (outsideSM.getGeometryClass() != null && outsideSM.getGeometryClass() == structureMapping.getGeometryClass()) {
return false;
}
}
return true;
}
use of cbit.vcell.model.Model.StructureTopology in project vcell by virtualcell.
the class MembraneStructureAnalyzer method refreshResolvedFluxes.
/**
* This method was created in VisualAge.
*/
void refreshResolvedFluxes() throws Exception {
// System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes()");
GeometryContext geoContext = mathMapping_4_8.getSimulationContext().getGeometryContext();
StructureTopology structTopology = mathMapping_4_8.getSimulationContext().getModel().getStructureTopology();
Vector<ResolvedFlux> resolvedFluxList = new Vector<ResolvedFlux>();
//
// for each reaction, get all fluxReactions associated with this membrane
//
Vector<ReactionStep> fluxList = new Vector<ReactionStep>();
ReactionSpec[] reactionSpecs = mathMapping_4_8.getSimulationContext().getReactionContext().getReactionSpecs();
for (int j = 0; j < reactionSpecs.length; j++) {
if (reactionSpecs[j].isExcluded()) {
continue;
}
ReactionStep rs = reactionSpecs[j].getReactionStep();
if (rs.getStructure() == getMembrane()) {
if (rs instanceof FluxReaction) {
fluxList.addElement(rs);
}
}
}
//
for (int i = 0; i < fluxList.size(); i++) {
FluxReaction fr = (FluxReaction) fluxList.elementAt(i);
Species fluxCarrier = null;
for (ReactionParticipant rp : fr.getReactionParticipants()) {
if (rp instanceof Reactant || rp instanceof Product) {
if (fluxCarrier == null) {
fluxCarrier = rp.getSpecies();
} else {
if (fluxCarrier != rp.getSpecies()) {
throw new Exception("Flux reaction '" + fr.getName() + "' with multiple species not allowed in VCell 4.8.");
}
}
}
}
if (fluxCarrier == null) {
continue;
}
ResolvedFlux rf = null;
for (int j = 0; j < resolvedFluxList.size(); j++) {
ResolvedFlux rf_tmp = (ResolvedFlux) resolvedFluxList.elementAt(j);
if (rf_tmp.getSpecies() == fluxCarrier) {
rf = rf_tmp;
}
}
//
// if "inside" speciesContext is not "fixed", add flux to ResolvedFlux
//
SpeciesContext insideSpeciesContext = mathMapping_4_8.getSimulationContext().getModel().getSpeciesContext(fluxCarrier, structTopology.getInsideFeature(getMembrane()));
SpeciesContextSpec insideSpeciesContextSpec = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(insideSpeciesContext);
// if (!insideSpeciesContextSpec.isConstant()){
if (bNoFluxIfFixed || !insideSpeciesContextSpec.isConstant()) {
if (bNoFluxIfFixed && insideSpeciesContextSpec.isConstant()) {
bNoFluxIfFixedExercised = true;
}
if (rf == null) {
rf = new ResolvedFlux(fluxCarrier, fr.getKinetics().getKineticsParameterFromRole(Kinetics.ROLE_ReactionRate).getUnitDefinition());
resolvedFluxList.addElement(rf);
}
FeatureMapping insideFeatureMapping = (FeatureMapping) geoContext.getStructureMapping((structTopology.getInsideFeature((Membrane) fr.getStructure())));
Expression residualVolumeFraction = mathMapping_4_8.getResidualVolumeFraction(insideFeatureMapping).renameBoundSymbols(mathMapping_4_8.getNameScope());
Expression insideFluxCorrection = Expression.invert(residualVolumeFraction);
//
if (bResolvedFluxCorrectionBug && !residualVolumeFraction.compareEqual(new Expression(1.0))) {
bResolvedFluxCorrectionBugExercised = true;
System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes() ... 'ResolvedFluxCorrection' bug compatability mode");
insideFluxCorrection = new Expression(1.0);
}
//
if (fr.getKinetics() instanceof DistributedKinetics) {
Expression reactionRateParameter = new Expression(((DistributedKinetics) fr.getKinetics()).getReactionRateParameter(), mathMapping_4_8.getNameScope());
if (rf.inFluxExpression.isZero()) {
rf.inFluxExpression = Expression.mult(reactionRateParameter, insideFluxCorrection).flatten();
} else {
rf.inFluxExpression = Expression.add(rf.inFluxExpression, Expression.mult(reactionRateParameter, insideFluxCorrection).flatten());
}
} else if (fr.getKinetics() instanceof LumpedKinetics) {
throw new RuntimeException("Lumped Kinetics for fluxes not yet supported");
} else {
throw new RuntimeException("unexpected Kinetic type in MembraneStructureAnalyzer.refreshResolvedFluxes()");
}
// rf.inFlux.bindExpression(mathMapping);
}
SpeciesContext outsideSpeciesContext = mathMapping_4_8.getSimulationContext().getModel().getSpeciesContext(fluxCarrier, structTopology.getOutsideFeature(getMembrane()));
SpeciesContextSpec outsideSpeciesContextSpec = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(outsideSpeciesContext);
// if (!outsideSpeciesContextSpec.isConstant()){
if (bNoFluxIfFixed || !outsideSpeciesContextSpec.isConstant()) {
if (bNoFluxIfFixed && outsideSpeciesContextSpec.isConstant()) {
bNoFluxIfFixedExercised = true;
}
if (rf == null) {
rf = new ResolvedFlux(fluxCarrier, fr.getKinetics().getKineticsParameterFromRole(Kinetics.ROLE_ReactionRate).getUnitDefinition());
resolvedFluxList.addElement(rf);
}
FeatureMapping outsideFeatureMapping = (FeatureMapping) geoContext.getStructureMapping(structTopology.getOutsideFeature((Membrane) fr.getStructure()));
Expression residualVolumeFraction = mathMapping_4_8.getResidualVolumeFraction(outsideFeatureMapping).renameBoundSymbols(mathMapping_4_8.getNameScope());
Expression outsideFluxCorrection = Expression.invert(residualVolumeFraction);
//
if (bResolvedFluxCorrectionBug && !residualVolumeFraction.compareEqual(new Expression(1.0))) {
bResolvedFluxCorrectionBugExercised = true;
System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes() ... 'ResolvedFluxCorrection' bug compatability mode");
outsideFluxCorrection = new Expression(1.0);
}
//
if (fr.getKinetics() instanceof DistributedKinetics) {
Expression reactionRateParameter = new Expression(((DistributedKinetics) fr.getKinetics()).getReactionRateParameter(), mathMapping_4_8.getNameScope());
if (rf.outFluxExpression.isZero()) {
rf.outFluxExpression = Expression.mult(Expression.negate(reactionRateParameter), outsideFluxCorrection).flatten();
} else {
rf.outFluxExpression = Expression.add(rf.outFluxExpression, Expression.mult(Expression.negate(reactionRateParameter), outsideFluxCorrection).flatten());
}
} else if (fr.getKinetics() instanceof LumpedKinetics) {
throw new RuntimeException("Lumped Kinetics not yet supported for Flux Reaction: " + fr.getName());
} else {
throw new RuntimeException("unexpected Kinetics type for Flux Reaction " + fr.getName());
}
// rf.outFlux.bindExpression(mathMapping);
}
}
//
// for each reaction, incorporate all reactionSteps involving binding with volumetric species
//
double kMoleValue = 1 / 602.0;
for (int i = 0; i < reactionSpecs.length; i++) {
if (reactionSpecs[i].isExcluded()) {
continue;
}
ReactionStep rs = reactionSpecs[i].getReactionStep();
if (rs.getStructure() == getMembrane()) {
if (rs instanceof SimpleReaction) {
SimpleReaction sr = (SimpleReaction) rs;
ReactionParticipant[] rp_Array = sr.getReactionParticipants();
for (int k = 0; k < rp_Array.length; k++) {
if (rp_Array[k] instanceof Reactant || rp_Array[k] instanceof Product) {
SpeciesContextSpec scs = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(rp_Array[k].getSpeciesContext());
// if (rp_Array[k].getStructure() instanceof Feature && !scs.isConstant()){
if (rp_Array[k].getStructure() instanceof Feature && (bNoFluxIfFixed || !scs.isConstant())) {
if (bNoFluxIfFixed && scs.isConstant()) {
bNoFluxIfFixedExercised = true;
}
//
// for each Reactant or Product binding to this membrane...
//
//
// get ResolvedFlux for this species
//
ResolvedFlux rf = null;
for (int j = 0; j < resolvedFluxList.size(); j++) {
ResolvedFlux rf_tmp = (ResolvedFlux) resolvedFluxList.elementAt(j);
if (rf_tmp.getSpecies() == rp_Array[k].getSpecies()) {
rf = rf_tmp;
}
}
if (rf == null) {
rf = new ResolvedFlux(rp_Array[k].getSpecies(), sr.getKinetics().getKineticsParameterFromRole(Kinetics.ROLE_ReactionRate).getUnitDefinition());
resolvedFluxList.addElement(rf);
}
Expression reactionRateExpression = getReactionRateExpression(sr, rp_Array[k]).renameBoundSymbols(mathMapping_4_8.getNameScope());
if (rp_Array[k].getStructure() == structTopology.getInsideFeature(getMembrane())) {
//
// for binding on inside, add to ResolvedFlux.inFlux
//
FeatureMapping insideFeatureMapping = (FeatureMapping) geoContext.getStructureMapping(structTopology.getInsideFeature(getMembrane()));
Expression residualVolumeFraction = mathMapping_4_8.getResidualVolumeFraction(insideFeatureMapping).renameBoundSymbols(mathMapping_4_8.getNameScope());
Expression insideFluxCorrection = Expression.div(new Expression(kMoleValue), residualVolumeFraction).flatten();
//
if (bResolvedFluxCorrectionBug && !residualVolumeFraction.compareEqual(new Expression(1.0))) {
bResolvedFluxCorrectionBugExercised = true;
System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes() ... 'ResolvedFluxCorrection' bug compatability mode");
insideFluxCorrection = new Expression(kMoleValue);
}
if (rf.inFluxExpression.isZero()) {
rf.inFluxExpression = Expression.mult(insideFluxCorrection, reactionRateExpression);
} else {
rf.inFluxExpression = Expression.add(rf.inFluxExpression, Expression.mult(insideFluxCorrection, reactionRateExpression));
}
// rf.inFlux.bindExpression(mathMapping);
} else if (rp_Array[k].getStructure() == structTopology.getOutsideFeature(getMembrane())) {
//
// for binding on outside, add to ResolvedFlux.outFlux
//
FeatureMapping outsideFeatureMapping = (FeatureMapping) geoContext.getStructureMapping(structTopology.getOutsideFeature(getMembrane()));
Expression residualVolumeFraction = mathMapping_4_8.getResidualVolumeFraction(outsideFeatureMapping).renameBoundSymbols(mathMapping_4_8.getNameScope());
Expression outsideFluxCorrection = Expression.div(new Expression(kMoleValue), residualVolumeFraction).flatten();
//
if (bResolvedFluxCorrectionBug && !residualVolumeFraction.compareEqual(new Expression(1.0))) {
bResolvedFluxCorrectionBugExercised = true;
System.out.println("MembraneStructureAnalyzer.refreshResolvedFluxes() ... 'ResolvedFluxCorrection' bug compatability mode");
outsideFluxCorrection = new Expression(kMoleValue);
}
if (rf.outFluxExpression.isZero()) {
rf.outFluxExpression = Expression.mult(outsideFluxCorrection, reactionRateExpression);
} else {
rf.outFluxExpression = Expression.add(rf.outFluxExpression, Expression.mult(outsideFluxCorrection, reactionRateExpression));
}
// rf.outFlux.bindExpression(mathMapping);
} else {
throw new Exception("SpeciesContext " + rp_Array[k].getSpeciesContext().getName() + " doesn't border membrane " + getMembrane().getName() + " but reacts there");
}
}
}
}
}
}
}
//
if (resolvedFluxList.size() > 0) {
resolvedFluxes = new ResolvedFlux[resolvedFluxList.size()];
resolvedFluxList.copyInto(resolvedFluxes);
} else {
resolvedFluxes = null;
}
}
Aggregations