Search in sources :

Example 21 with ReactionSpec

use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.

the class StructureAnalyzer method refreshFastSpeciesContextMappings.

/**
 * This method was created in VisualAge.
 */
private void refreshFastSpeciesContextMappings() {
    // System.out.println("StructureAnalyzer.refreshFastSpeciesContextMappings()");
    // GeometryContext geoContext = mathMapping.getSimulationContext().getGeometryContext();
    Vector<SpeciesContextMapping> scFastList = new Vector<SpeciesContextMapping>();
    // 
    if (structures == null) {
        return;
    }
    for (int i = 0; i < structures.length; i++) {
        SpeciesContext[] speciesContexts = mathMapping_4_8.getSimulationContext().getReactionContext().getModel().getSpeciesContexts(structures[i]);
        for (int j = 0; j < speciesContexts.length; j++) {
            SpeciesContext sc = speciesContexts[j];
            SpeciesContextMapping scm = mathMapping_4_8.getSpeciesContextMapping(sc);
            SpeciesContextSpec scs = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(sc);
            if (scm.getDependencyExpression() == null && scs.isConstant() == false) {
                // right now all independent vars
                scFastList.addElement(scm);
            }
        }
    }
    if (scFastList.size() > 0) {
        fastSpeciesContextMappings = new SpeciesContextMapping[scFastList.size()];
        scFastList.copyInto(fastSpeciesContextMappings);
    // for (int i=0;i<fastSpeciesContextMappings.length;i++){
    // System.out.println("fastSpeciesContextMappings["+i+"] = "+fastSpeciesContextMappings[i].getSpeciesContext().getName());
    // }
    } else {
        fastSpeciesContextMappings = null;
    }
    // System.out.println("StructureAnalyzer.refreshFastSpeciesContextMapping(), fastSpeciesContextMappings.length = "+scFastList.size());
    // 
    // for each reaction, get all reactionSteps associated with these structures
    // 
    Vector<ReactionStep> rsFastList = new Vector<ReactionStep>();
    ReactionSpec[] reactionSpecs = mathMapping_4_8.getSimulationContext().getReactionContext().getReactionSpecs();
    for (int i = 0; i < reactionSpecs.length; i++) {
        ReactionStep rs = reactionSpecs[i].getReactionStep();
        if (reactionSpecs[i].isExcluded()) {
            continue;
        }
        for (int j = 0; j < structures.length; j++) {
            if (rs.getStructure() == structures[j]) {
                if (reactionSpecs[i].isFast()) {
                    rsFastList.addElement(rs);
                }
            }
        }
    }
    if (rsFastList.size() > 0) {
        fastReactionSteps = new ReactionStep[rsFastList.size()];
        rsFastList.copyInto(fastReactionSteps);
    } else {
        fastReactionSteps = null;
        fastSpeciesContextMappings = null;
    }
// System.out.println("StructureAnalyzer.refreshFastSpeciesContextMapping(), reactionSteps.length = "+scFastList.size());
}
Also used : SpeciesContextMapping(cbit.vcell.mapping.SpeciesContextMapping) ReactionSpec(cbit.vcell.mapping.ReactionSpec) DummyReactionStep(cbit.vcell.mapping.DummyReactionStep) ReactionStep(cbit.vcell.model.ReactionStep) EventDummyReactionStep(cbit.vcell.mapping.EventDummyReactionStep) ParticleDummyReactionStep(cbit.vcell.mapping.ParticleDummyReactionStep) DiffusionDummyReactionStep(cbit.vcell.mapping.DiffusionDummyReactionStep) HybridDummyReactionStep(cbit.vcell.mapping.HybridDummyReactionStep) SpeciesContext(cbit.vcell.model.SpeciesContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) Vector(java.util.Vector)

Example 22 with ReactionSpec

use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.

the class StructureAnalyzer method refreshTotalSpeciesContextMappings.

/**
 * This method was created in VisualAge.
 */
private void refreshTotalSpeciesContextMappings() throws java.beans.PropertyVetoException {
    if (structures == null) {
        return;
    }
    // System.out.println("StructureAnalyzer.refreshSpeciesContextMappings()");
    // GeometryContext geoContext = mathMapping.getSimulationContext().getGeometryContext();
    Model model = mathMapping_4_8.getSimulationContext().getReactionContext().getModel();
    // 
    // note, the order of species is specified such that the first species have priority
    // when the null space is solved for dependent variables.  So the order of priority
    // for elimination are as follows:
    // 
    // 1) Species involved with fast reactions.
    // 2) Species not involved with fast reactions.
    // 
    Vector<SpeciesContextMapping> scmList = new Vector<SpeciesContextMapping>();
    // 
    for (int i = 0; i < structures.length; i++) {
        SpeciesContext[] speciesContexts = model.getSpeciesContexts(structures[i]);
        for (int j = 0; j < speciesContexts.length; j++) {
            SpeciesContext sc = speciesContexts[j];
            SpeciesContextMapping scm = mathMapping_4_8.getSpeciesContextMapping(sc);
            SpeciesContextSpec scs = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(sc);
            if (scm.isFastParticipant() && !scs.isConstant()) {
                scmList.addElement(scm);
            }
        }
    }
    // 
    for (int i = 0; i < structures.length; i++) {
        SpeciesContext[] speciesContexts = model.getSpeciesContexts(structures[i]);
        for (int j = 0; j < speciesContexts.length; j++) {
            SpeciesContext sc = speciesContexts[j];
            SpeciesContextMapping scm = mathMapping_4_8.getSpeciesContextMapping(sc);
            SpeciesContextSpec scs = mathMapping_4_8.getSimulationContext().getReactionContext().getSpeciesContextSpec(sc);
            if (!scm.isFastParticipant() && !scs.isConstant()) {
                scmList.addElement(scm);
            }
        }
    }
    if (scmList.size() > 0) {
        speciesContextMappings = new SpeciesContextMapping[scmList.size()];
        scmList.copyInto(speciesContextMappings);
        for (int i = 0; i < speciesContextMappings.length; i++) {
            speciesContextMappings[i].setRate(new Expression(0.0));
        // System.out.println("speciesContextMappings["+i+"] = "+speciesContextMappings[i].getSpeciesContext().getName());
        }
    } else {
        speciesContextMappings = null;
    }
    // System.out.println("StructureAnalyzer.refreshTotalSpeciesContextMapping(), speciesContextMappings.length = "+scmList.size());
    // 
    // get all reactionSteps associated with these structures
    // 
    Vector<ReactionStep> rsList = new Vector<ReactionStep>();
    ReactionSpec[] allReactionSpecs = mathMapping_4_8.getSimulationContext().getReactionContext().getReactionSpecs();
    for (int i = 0; i < allReactionSpecs.length; i++) {
        if (allReactionSpecs[i].isExcluded()) {
            continue;
        }
        ReactionStep rs = allReactionSpecs[i].getReactionStep();
        for (int j = 0; j < structures.length; j++) {
            if (rs.getStructure() == structures[j]) {
                rsList.addElement(rs);
            }
        }
    }
    // 
    for (int i = 0; i < scmList.size(); i++) {
        SpeciesContextMapping scm = (SpeciesContextMapping) scmList.elementAt(i);
        if (scm.isPDERequired()) {
            rsList.addElement(new DiffusionDummyReactionStep("DiffusionDummyReactionStep" + i, model, scm.getSpeciesContext().getStructure(), scm.getSpeciesContext()));
        }
        if (scm.hasEventAssignment()) {
            rsList.addElement(new EventDummyReactionStep("EventDummyReactionStep" + i, model, scm.getSpeciesContext().getStructure(), scm.getSpeciesContext()));
        }
        if (scm.hasHybridReaction()) {
            rsList.addElement(new HybridDummyReactionStep("HybridDummyReactionStep" + i, model, scm.getSpeciesContext().getStructure(), scm.getSpeciesContext()));
        }
        SimulationContext simContext = mathMapping_4_8.getSimulationContext();
        if (simContext.isStoch() && simContext.getGeometry().getDimension() > 0 && !simContext.getReactionContext().getSpeciesContextSpec(scm.getSpeciesContext()).isForceContinuous()) {
            rsList.addElement(new ParticleDummyReactionStep("ParticleDummyReactionStep" + i, model, scm.getSpeciesContext().getStructure(), scm.getSpeciesContext()));
        }
    }
    if (rsList.size() > 0) {
        reactionSteps = new ReactionStep[rsList.size()];
        rsList.copyInto(reactionSteps);
    } else {
        reactionSteps = null;
    }
// System.out.println("StructureAnalyzer.refreshTotalSpeciesContextMapping(), reactionSteps.length = "+scmList.size());
}
Also used : ParticleDummyReactionStep(cbit.vcell.mapping.ParticleDummyReactionStep) SpeciesContextMapping(cbit.vcell.mapping.SpeciesContextMapping) ReactionSpec(cbit.vcell.mapping.ReactionSpec) EventDummyReactionStep(cbit.vcell.mapping.EventDummyReactionStep) SpeciesContext(cbit.vcell.model.SpeciesContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) SimulationContext(cbit.vcell.mapping.SimulationContext) Expression(cbit.vcell.parser.Expression) DummyReactionStep(cbit.vcell.mapping.DummyReactionStep) ReactionStep(cbit.vcell.model.ReactionStep) EventDummyReactionStep(cbit.vcell.mapping.EventDummyReactionStep) ParticleDummyReactionStep(cbit.vcell.mapping.ParticleDummyReactionStep) DiffusionDummyReactionStep(cbit.vcell.mapping.DiffusionDummyReactionStep) HybridDummyReactionStep(cbit.vcell.mapping.HybridDummyReactionStep) Model(cbit.vcell.model.Model) HybridDummyReactionStep(cbit.vcell.mapping.HybridDummyReactionStep) Vector(java.util.Vector) DiffusionDummyReactionStep(cbit.vcell.mapping.DiffusionDummyReactionStep)

Example 23 with ReactionSpec

use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of a ReactionContext object.
 * Creation date: (3/1/2001 9:03:52 PM)
 * @return Element
 * @param param cbit.vcell.mapping.ReactionContext
 */
private Element getXML(ReactionContext param) {
    Element reactioncontext = new Element(XMLTags.ReactionContextTag);
    // Add SpeciesContextSpecs
    SpeciesContextSpec[] array = param.getSpeciesContextSpecs();
    for (int i = 0; i < array.length; i++) {
        reactioncontext.addContent(getXML(array[i]));
    }
    // Add ReactionSpecs
    ReactionSpec[] reactionarray = param.getReactionSpecs();
    for (int i = 0; i < reactionarray.length; i++) {
        reactioncontext.addContent(getXML(reactionarray[i]));
    }
    // Add ReactionRuleSpecs
    ReactionRuleSpec[] reactionRuleArray = param.getReactionRuleSpecs();
    if (reactionRuleArray.length > 0) {
        reactioncontext.addContent(getXML(reactionRuleArray));
    }
    return reactioncontext;
}
Also used : ReactionSpec(cbit.vcell.mapping.ReactionSpec) ReactionRuleSpec(cbit.vcell.mapping.ReactionRuleSpec) Element(org.jdom.Element) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec)

Example 24 with ReactionSpec

use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.

the class ModelOptimizationSpec method getModelParameters.

/**
 * Insert the method's description here.
 * Creation date: (8/22/2005 10:38:04 AM)
 * @return cbit.vcell.model.Parameter[]
 */
private Parameter[] getModelParameters() {
    java.util.Vector<Parameter> modelParameterList = new java.util.Vector<Parameter>();
    Model model = getSimulationContext().getModel();
    // 
    // get Model (global) parameters
    // 
    ModelParameter[] globalParams = model.getModelParameters();
    for (int i = 0; i < globalParams.length; i++) {
        if (globalParams[i] != null && globalParams[i].getExpression() != null && globalParams[i].getExpression().isNumeric()) {
            modelParameterList.add(globalParams[i]);
        }
    }
    // 
    // get kinetic parameters that are numbers
    // 
    ReactionStep[] reactionSteps = model.getReactionSteps();
    for (int i = 0; i < reactionSteps.length; i++) {
        // 
        // make sure ReactionSteps are "enabled"
        // 
        ReactionSpec reactionSpec = getSimulationContext().getReactionContext().getReactionSpec(reactionSteps[i]);
        if (reactionSpec == null || reactionSpec.isExcluded()) {
            continue;
        }
        Kinetics.KineticsParameter[] kineticsParameters = reactionSteps[i].getKinetics().getKineticsParameters();
        for (int j = 0; j < kineticsParameters.length; j++) {
            if (kineticsParameters[j].getExpression() != null && kineticsParameters[j].getExpression().isNumeric()) {
                if (((kineticsParameters[j].getRole() == Kinetics.ROLE_CurrentDensity) || (kineticsParameters[j].getRole() == Kinetics.ROLE_LumpedCurrent)) && reactionSteps[i].getPhysicsOptions() == ReactionStep.PHYSICS_MOLECULAR_ONLY) {
                    continue;
                }
                if (((kineticsParameters[j].getRole() == Kinetics.ROLE_ReactionRate) || (kineticsParameters[j].getRole() == Kinetics.ROLE_LumpedReactionRate)) && reactionSteps[i].getPhysicsOptions() == ReactionStep.PHYSICS_ELECTRICAL_ONLY) {
                    continue;
                }
                modelParameterList.add(kineticsParameters[j]);
            }
        }
    }
    // 
    // get initial conditions that are numbers
    // 
    SpeciesContextSpec[] speciesContextSpecs = getSimulationContext().getReactionContext().getSpeciesContextSpecs();
    for (int i = 0; i < speciesContextSpecs.length; i++) {
        SpeciesContextSpec.SpeciesContextSpecParameter initParam = speciesContextSpecs[i].getInitialConditionParameter();
        if (initParam != null && initParam.getExpression() != null && initParam.getExpression().isNumeric()) {
            modelParameterList.add(initParam);
        }
    }
    // 
    // get structure parameters
    // 
    StructureMapping[] structureMappings = getSimulationContext().getGeometryContext().getStructureMappings();
    for (int i = 0; i < structureMappings.length; i++) {
        StructureMapping.StructureMappingParameter[] parameters = structureMappings[i].getParameters();
        for (int j = 0; j < parameters.length; j++) {
            if (parameters[j].getRole() == StructureMapping.ROLE_SpecificCapacitance && structureMappings[i] instanceof MembraneMapping && !((MembraneMapping) structureMappings[i]).getCalculateVoltage()) {
                continue;
            }
            if (parameters[j].getExpression() != null && parameters[j].getExpression().isNumeric()) {
                modelParameterList.add(parameters[j]);
            }
        }
    }
    Parameter[] modelParameters = (Parameter[]) BeanUtils.getArray(modelParameterList, Parameter.class);
    return modelParameters;
}
Also used : MembraneMapping(cbit.vcell.mapping.MembraneMapping) ReactionSpec(cbit.vcell.mapping.ReactionSpec) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) ModelParameter(cbit.vcell.model.Model.ModelParameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) ReactionStep(cbit.vcell.model.ReactionStep) Model(cbit.vcell.model.Model) Parameter(cbit.vcell.model.Parameter) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) ModelParameter(cbit.vcell.model.Model.ModelParameter) KineticsProxyParameter(cbit.vcell.model.Kinetics.KineticsProxyParameter) SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter) Vector(java.util.Vector) SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)

Aggregations

ReactionSpec (cbit.vcell.mapping.ReactionSpec)24 ReactionStep (cbit.vcell.model.ReactionStep)15 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)12 Expression (cbit.vcell.parser.Expression)11 SpeciesContext (cbit.vcell.model.SpeciesContext)9 SpeciesContextMapping (cbit.vcell.mapping.SpeciesContextMapping)8 MembraneMapping (cbit.vcell.mapping.MembraneMapping)7 StructureMapping (cbit.vcell.mapping.StructureMapping)7 Model (cbit.vcell.model.Model)7 Structure (cbit.vcell.model.Structure)7 SimulationContext (cbit.vcell.mapping.SimulationContext)6 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)6 ReactionParticipant (cbit.vcell.model.ReactionParticipant)6 SimpleReaction (cbit.vcell.model.SimpleReaction)6 ReactionRuleSpec (cbit.vcell.mapping.ReactionRuleSpec)5 Membrane (cbit.vcell.model.Membrane)5 Parameter (cbit.vcell.model.Parameter)5 ExpressionException (cbit.vcell.parser.ExpressionException)5 PropertyVetoException (java.beans.PropertyVetoException)5 Vector (java.util.Vector)5