Search in sources :

Example 1 with ElectricalStimulus

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

the class ElectricalStimulusParameterTableModel method propertyChange.

/**
 * This method gets called when a bound property is changed.
 * @param evt A PropertyChangeEvent object describing the event source
 *   and the property that has changed.
 */
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    if (evt.getSource() == this && evt.getPropertyName().equals("electricalStimulus")) {
        ElectricalStimulus oldValue = (ElectricalStimulus) evt.getOldValue();
        if (oldValue != null) {
            oldValue.removePropertyChangeListener(this);
            Parameter[] oldParameters = oldValue.getParameters();
            for (int i = 0; i < oldParameters.length; i++) {
                oldParameters[i].removePropertyChangeListener(this);
            }
        }
        ElectricalStimulus newValue = (ElectricalStimulus) evt.getNewValue();
        if (newValue != null) {
            newValue.addPropertyChangeListener(this);
            Parameter[] newParameters = newValue.getParameters();
            for (int i = 0; i < newParameters.length; i++) {
                newParameters[i].addPropertyChangeListener(this);
            }
        }
        refreshData();
    }
    if (evt.getSource() instanceof ElectricalStimulus && (evt.getPropertyName().equals("localParameters") || evt.getPropertyName().equals("proxyParameters"))) {
        Parameter[] oldParameters = (Parameter[]) evt.getOldValue();
        for (int i = 0; i < oldParameters.length; i++) {
            oldParameters[i].removePropertyChangeListener(this);
        }
        Parameter[] newParameters = (Parameter[]) evt.getNewValue();
        for (int i = 0; i < newParameters.length; i++) {
            newParameters[i].addPropertyChangeListener(this);
        }
        refreshData();
    }
    if (evt.getSource() instanceof LocalParameter && evt.getPropertyName().equals("expression")) {
        fireTableRowsUpdated(0, getRowCount() - 1);
    }
}
Also used : LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) ElectricalStimulus(cbit.vcell.mapping.ElectricalStimulus) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) Parameter(cbit.vcell.model.Parameter) ProxyParameter(cbit.vcell.model.ProxyParameter)

Example 2 with ElectricalStimulus

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

the class ElectricalStimulusParameterTableModel method setElectricalStimulus.

/**
 * Sets the electricalStimulus property (cbit.vcell.mapping.ElectricalStimulus) value.
 * @param electricalStimulus The new value for the property.
 * @see #getElectricalStimulus
 */
public void setElectricalStimulus(ElectricalStimulus electricalStimulus) {
    ElectricalStimulus oldValue = fieldElectricalStimulus;
    fieldElectricalStimulus = electricalStimulus;
    if (electricalStimulus != null) {
        autoCompleteSymbolFilter = electricalStimulus.getAutoCompleteSymbolFilter();
    }
    firePropertyChange("electricalStimulus", oldValue, electricalStimulus);
}
Also used : ElectricalStimulus(cbit.vcell.mapping.ElectricalStimulus)

Example 3 with ElectricalStimulus

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

the class BioModelParametersTableModel method propertyChange.

@Override
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    super.propertyChange(evt);
    if (evt.getSource() instanceof EditableSymbolTableEntry) {
        int changeRow = getRowIndex((EditableSymbolTableEntry) evt.getSource());
        if (changeRow >= 0) {
            fireTableRowsUpdated(changeRow, changeRow);
        }
    } else {
        String propertyName = evt.getPropertyName();
        if (evt.getSource() == bioModel.getModel()) {
            if (propertyName.equals(Model.PROPERTY_NAME_MODEL_PARAMETERS)) {
                ModelParameter[] oldValue = (ModelParameter[]) evt.getOldValue();
                if (oldValue != null) {
                    for (EditableSymbolTableEntry parameter : oldValue) {
                        parameter.removePropertyChangeListener(this);
                    }
                }
                ModelParameter[] newValue = (ModelParameter[]) evt.getNewValue();
                if (newValue != null) {
                    for (EditableSymbolTableEntry parameter : newValue) {
                        parameter.addPropertyChangeListener(this);
                    }
                }
                refreshData();
            } else if (propertyName.equals(Model.PROPERTY_NAME_SPECIES_CONTEXTS)) {
                SpeciesContext[] oldValue = (SpeciesContext[]) evt.getOldValue();
                if (oldValue != null) {
                    for (SpeciesContext sc : oldValue) {
                        sc.removePropertyChangeListener(this);
                    }
                }
                SpeciesContext[] newValue = (SpeciesContext[]) evt.getNewValue();
                if (newValue != null) {
                    for (SpeciesContext sc : newValue) {
                        sc.addPropertyChangeListener(this);
                    }
                }
                refreshData();
            } else if (propertyName.equals(Model.PROPERTY_NAME_REACTION_STEPS)) {
                ReactionStep[] oldValue = (ReactionStep[]) evt.getOldValue();
                if (oldValue != null) {
                    for (ReactionStep reactionStep : oldValue) {
                        reactionStep.removePropertyChangeListener(this);
                        reactionStep.getKinetics().removePropertyChangeListener(this);
                        for (KineticsParameter kineticsEditableSymbolTableEntry : reactionStep.getKinetics().getKineticsParameters()) {
                            kineticsEditableSymbolTableEntry.removePropertyChangeListener(this);
                        }
                        for (ProxyParameter proxyEditableSymbolTableEntry : reactionStep.getKinetics().getProxyParameters()) {
                            proxyEditableSymbolTableEntry.removePropertyChangeListener(this);
                        }
                        for (UnresolvedParameter unresolvedEditableSymbolTableEntry : reactionStep.getKinetics().getUnresolvedParameters()) {
                            unresolvedEditableSymbolTableEntry.removePropertyChangeListener(this);
                        }
                    }
                }
                ReactionStep[] newValue = (ReactionStep[]) evt.getNewValue();
                if (newValue != null) {
                    for (ReactionStep reactionStep : newValue) {
                        reactionStep.addPropertyChangeListener(this);
                        reactionStep.getKinetics().addPropertyChangeListener(this);
                        for (KineticsParameter kineticsEditableSymbolTableEntry : reactionStep.getKinetics().getKineticsParameters()) {
                            kineticsEditableSymbolTableEntry.addPropertyChangeListener(this);
                        }
                        for (ProxyParameter proxyEditableSymbolTableEntry : reactionStep.getKinetics().getProxyParameters()) {
                            proxyEditableSymbolTableEntry.addPropertyChangeListener(this);
                        }
                        for (UnresolvedParameter unresolvedEditableSymbolTableEntry : reactionStep.getKinetics().getUnresolvedParameters()) {
                            unresolvedEditableSymbolTableEntry.addPropertyChangeListener(this);
                        }
                    }
                }
                refreshData();
            } else if (evt.getPropertyName().equals(RbmModelContainer.PROPERTY_NAME_REACTION_RULE_LIST)) {
                List<ReactionRule> oldValue = (List<ReactionRule>) evt.getOldValue();
                if (oldValue != null) {
                    for (ReactionRule rs : oldValue) {
                        rs.removePropertyChangeListener(this);
                    }
                }
                List<ReactionRule> newValue = (List<ReactionRule>) evt.getNewValue();
                if (newValue != null) {
                    for (ReactionRule rs : newValue) {
                        rs.addPropertyChangeListener(this);
                    }
                }
                refreshData();
            }
        } else if (evt.getSource() == bioModel) {
            if (propertyName.equals(BioModel.PROPERTY_NAME_SIMULATION_CONTEXTS)) {
                SimulationContext[] oldValue = (SimulationContext[]) evt.getOldValue();
                for (SimulationContext simulationContext : oldValue) {
                    simulationContext.removePropertyChangeListener(this);
                    simulationContext.getGeometryContext().removePropertyChangeListener(this);
                    for (StructureMapping mapping : simulationContext.getGeometryContext().getStructureMappings()) {
                        mapping.removePropertyChangeListener(this);
                        for (EditableSymbolTableEntry parameter : mapping.getParameters()) {
                            parameter.removePropertyChangeListener(this);
                        }
                    }
                    simulationContext.getReactionContext().removePropertyChangeListener(this);
                    for (SpeciesContextSpec spec : simulationContext.getReactionContext().getSpeciesContextSpecs()) {
                        spec.removePropertyChangeListener(this);
                        for (EditableSymbolTableEntry parameter : spec.getParameters()) {
                            parameter.removePropertyChangeListener(this);
                        }
                    }
                    for (ElectricalStimulus elect : simulationContext.getElectricalStimuli()) {
                        elect.removePropertyChangeListener(this);
                        for (EditableSymbolTableEntry parameter : elect.getParameters()) {
                            parameter.removePropertyChangeListener(this);
                        }
                    }
                    for (SpatialObject spatialObject : simulationContext.getSpatialObjects()) {
                        spatialObject.removePropertyChangeListener(this);
                    }
                    for (SpatialProcess spatialProcess : simulationContext.getSpatialProcesses()) {
                        spatialProcess.removePropertyChangeListener(this);
                        for (LocalParameter p : spatialProcess.getParameters()) {
                            p.removePropertyChangeListener(this);
                        }
                    }
                    for (SimulationContextParameter p : simulationContext.getSimulationContextParameters()) {
                        p.removePropertyChangeListener(this);
                    }
                }
                SimulationContext[] newValue = (SimulationContext[]) evt.getNewValue();
                for (SimulationContext simulationContext : newValue) {
                    simulationContext.addPropertyChangeListener(this);
                    simulationContext.getGeometryContext().addPropertyChangeListener(this);
                    for (StructureMapping mapping : simulationContext.getGeometryContext().getStructureMappings()) {
                        mapping.addPropertyChangeListener(this);
                        for (EditableSymbolTableEntry parameter : mapping.getParameters()) {
                            parameter.addPropertyChangeListener(this);
                        }
                    }
                    simulationContext.getReactionContext().addPropertyChangeListener(this);
                    for (SpeciesContextSpec spec : simulationContext.getReactionContext().getSpeciesContextSpecs()) {
                        spec.addPropertyChangeListener(this);
                        for (EditableSymbolTableEntry parameter : spec.getParameters()) {
                            parameter.addPropertyChangeListener(this);
                        }
                    }
                    for (ElectricalStimulus elect : simulationContext.getElectricalStimuli()) {
                        elect.addPropertyChangeListener(this);
                        for (EditableSymbolTableEntry parameter : elect.getParameters()) {
                            parameter.addPropertyChangeListener(this);
                        }
                    }
                    for (SpatialObject spatialObject : simulationContext.getSpatialObjects()) {
                        spatialObject.addPropertyChangeListener(this);
                    }
                    for (SpatialProcess spatialProcess : simulationContext.getSpatialProcesses()) {
                        spatialProcess.addPropertyChangeListener(this);
                        for (LocalParameter p : spatialProcess.getParameters()) {
                            p.addPropertyChangeListener(this);
                        }
                    }
                    for (SimulationContextParameter p : simulationContext.getSimulationContextParameters()) {
                        p.addPropertyChangeListener(this);
                    }
                }
                refreshData();
            }
        } else if (evt.getSource() instanceof GeometryContext && evt.getPropertyName().equals(GeometryContext.PROPERTY_STRUCTURE_MAPPINGS)) {
            StructureMapping[] oldValue = (StructureMapping[]) evt.getOldValue();
            if (oldValue != null) {
                for (StructureMapping mapping : oldValue) {
                    mapping.removePropertyChangeListener(this);
                    for (EditableSymbolTableEntry parameter : mapping.getParameters()) {
                        parameter.removePropertyChangeListener(this);
                    }
                }
            }
            StructureMapping[] newValue = (StructureMapping[]) evt.getNewValue();
            if (newValue != null) {
                for (StructureMapping mapping : newValue) {
                    mapping.addPropertyChangeListener(this);
                    for (EditableSymbolTableEntry parameter : mapping.getParameters()) {
                        parameter.addPropertyChangeListener(this);
                    }
                }
            }
            refreshData();
        } else if (evt.getSource() instanceof ReactionStep && (evt.getPropertyName().equals(ReactionStep.PROPERTY_NAME_KINETICS))) {
            Kinetics oldValue = (Kinetics) evt.getOldValue();
            if (oldValue != null) {
                oldValue.removePropertyChangeListener(this);
                for (KineticsParameter kineticsEditableSymbolTableEntry : oldValue.getKineticsParameters()) {
                    kineticsEditableSymbolTableEntry.removePropertyChangeListener(this);
                }
                for (ProxyParameter proxyEditableSymbolTableEntry : oldValue.getProxyParameters()) {
                    proxyEditableSymbolTableEntry.removePropertyChangeListener(this);
                }
                for (UnresolvedParameter unresolvedEditableSymbolTableEntry : oldValue.getUnresolvedParameters()) {
                    unresolvedEditableSymbolTableEntry.removePropertyChangeListener(this);
                }
            }
            Kinetics newValue = (Kinetics) evt.getNewValue();
            if (newValue != null) {
                newValue.addPropertyChangeListener(this);
                for (KineticsParameter kineticsEditableSymbolTableEntry : newValue.getKineticsParameters()) {
                    kineticsEditableSymbolTableEntry.addPropertyChangeListener(this);
                }
                for (ProxyParameter proxyEditableSymbolTableEntry : newValue.getProxyParameters()) {
                    proxyEditableSymbolTableEntry.addPropertyChangeListener(this);
                }
                for (UnresolvedParameter unresolvedEditableSymbolTableEntry : newValue.getUnresolvedParameters()) {
                    unresolvedEditableSymbolTableEntry.addPropertyChangeListener(this);
                }
            }
            refreshData();
        } else if (evt.getSource() instanceof SimulationContext && evt.getPropertyName().equals(SimulationContext.PROPERTY_NAME_SPATIALPROCESSES)) {
            SpatialProcess[] oldValue = (SpatialProcess[]) evt.getOldValue();
            if (oldValue != null) {
                for (SpatialProcess process : oldValue) {
                    process.removePropertyChangeListener(this);
                    for (EditableSymbolTableEntry parameter : process.getParameters()) {
                        parameter.removePropertyChangeListener(this);
                    }
                }
            }
            SpatialProcess[] newValue = (SpatialProcess[]) evt.getNewValue();
            if (newValue != null) {
                for (SpatialProcess process : newValue) {
                    process.addPropertyChangeListener(this);
                    for (EditableSymbolTableEntry parameter : process.getParameters()) {
                        parameter.addPropertyChangeListener(this);
                    }
                }
            }
            refreshData();
        } else if (evt.getSource() instanceof SimulationContext && evt.getPropertyName().equals(SimulationContext.PROPERTY_NAME_SPATIALOBJECTS)) {
            SpatialObject[] oldValue = (SpatialObject[]) evt.getOldValue();
            if (oldValue != null) {
                for (SpatialObject spatialObject : oldValue) {
                    spatialObject.removePropertyChangeListener(this);
                }
            }
            SpatialObject[] newValue = (SpatialObject[]) evt.getNewValue();
            if (newValue != null) {
                for (SpatialObject spatialObject : newValue) {
                    spatialObject.addPropertyChangeListener(this);
                }
            }
            refreshData();
        } else if (evt.getSource() instanceof SpatialObject && evt.getPropertyName().equals(SpatialObject.PROPERTY_NAME_QUANTITYCATEGORIESENABLED)) {
            refreshData();
        } else if (evt.getSource() instanceof SimulationContext && evt.getPropertyName().equals(SimulationContext.PROPERTY_NAME_SIMULATIONCONTEXTPARAMETERS)) {
            SimulationContextParameter[] oldValue = (SimulationContextParameter[]) evt.getOldValue();
            if (oldValue != null) {
                for (SimulationContextParameter param : oldValue) {
                    param.removePropertyChangeListener(this);
                }
            }
            SimulationContextParameter[] newValue = (SimulationContextParameter[]) evt.getNewValue();
            if (newValue != null) {
                for (SimulationContextParameter param : newValue) {
                    param.addPropertyChangeListener(this);
                }
            }
            refreshData();
        } else if (evt.getSource() instanceof Kinetics && (evt.getPropertyName().equals(Kinetics.PROPERTY_NAME_KINETICS_PARAMETERS))) {
            EditableSymbolTableEntry[] oldValue = (EditableSymbolTableEntry[]) evt.getOldValue();
            if (oldValue != null) {
                for (int i = 0; i < oldValue.length; i++) {
                    oldValue[i].removePropertyChangeListener(this);
                }
            }
            EditableSymbolTableEntry[] newValue = (EditableSymbolTableEntry[]) evt.getNewValue();
            if (newValue != null) {
                for (int i = 0; i < newValue.length; i++) {
                    newValue[i].addPropertyChangeListener(this);
                }
            }
            refreshData();
        // } else if(evt.getSource() instanceof ReactionRuleEmbedded) {
        // ReactionRuleEmbedded reactionRule = (ReactionRuleEmbedded) evt.getSource();
        // int changeRow = getRowIndex(reactionRule);
        // if (changeRow >= 0) {
        // fireTableRowsUpdated(changeRow, changeRow);
        // }
        }
    }
}
Also used : UnresolvedParameter(cbit.vcell.model.Kinetics.UnresolvedParameter) SpeciesContext(cbit.vcell.model.SpeciesContext) SpeciesContextSpec(cbit.vcell.mapping.SpeciesContextSpec) StructureMapping(cbit.vcell.mapping.StructureMapping) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) SpatialProcess(cbit.vcell.mapping.spatial.processes.SpatialProcess) ArrayList(java.util.ArrayList) List(java.util.List) GeometryContext(cbit.vcell.mapping.GeometryContext) ReactionRule(cbit.vcell.model.ReactionRule) SimulationContext(cbit.vcell.mapping.SimulationContext) SimulationContextParameter(cbit.vcell.mapping.SimulationContext.SimulationContextParameter) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) ModelParameter(cbit.vcell.model.Model.ModelParameter) ElectricalStimulus(cbit.vcell.mapping.ElectricalStimulus) ProxyParameter(cbit.vcell.model.ProxyParameter) ReactionStep(cbit.vcell.model.ReactionStep) Kinetics(cbit.vcell.model.Kinetics) EditableSymbolTableEntry(cbit.vcell.model.EditableSymbolTableEntry)

Example 4 with ElectricalStimulus

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

the class ITextWriter method writeMembraneMapping.

protected void writeMembraneMapping(Section simContextSection, SimulationContext simContext) throws DocumentException {
    GeometryContext geoContext = simContext.getGeometryContext();
    if (geoContext == null) {
        return;
    }
    Section memMapSection = null;
    Table memMapTable = null;
    StructureMapping[] structMappings = geoContext.getStructureMappings();
    for (int i = 0; i < structMappings.length; i++) {
        MembraneMapping memMapping = null;
        if (structMappings[i] instanceof FeatureMapping) {
            continue;
        } else {
            memMapping = (MembraneMapping) structMappings[i];
        }
        String structName = memMapping.getStructure().getName();
        String initVoltage = "";
        Expression tempExp = memMapping.getInitialVoltageParameter().getExpression();
        VCUnitDefinition tempUnit = memMapping.getInitialVoltageParameter().getUnitDefinition();
        if (tempExp != null) {
            initVoltage = tempExp.infix();
            if (tempUnit != null) {
                initVoltage += "   " + tempUnit.getSymbolUnicode();
            }
        }
        String spCap = "";
        tempExp = memMapping.getSpecificCapacitanceParameter().getExpression();
        tempUnit = memMapping.getSpecificCapacitanceParameter().getUnitDefinition();
        if (tempExp != null) {
            spCap = tempExp.infix();
            if (tempUnit != null) {
                spCap += "   " + tempUnit.getSymbolUnicode();
            }
        }
        if (memMapTable == null) {
            memMapTable = getTable(4, 100, 1, 3, 3);
            memMapTable.addCell(createCell("Electrical Mapping - Membrane Potential", getBold(DEF_HEADER_FONT_SIZE), 4, 1, Element.ALIGN_CENTER, true));
            memMapTable.addCell(createHeaderCell("Membrane", getBold(), 1));
            memMapTable.addCell(createHeaderCell("Calculate V (T/F)", getBold(), 1));
            memMapTable.addCell(createHeaderCell("V initial", getBold(), 1));
            memMapTable.addCell(createHeaderCell("Specific Capacitance", getBold(), 1));
            memMapTable.endHeaders();
        }
        memMapTable.addCell(createCell(structName, getFont()));
        memMapTable.addCell(createCell((memMapping.getCalculateVoltage() ? " T " : " F "), getFont()));
        memMapTable.addCell(createCell(initVoltage, getFont()));
        memMapTable.addCell(createCell(spCap, getFont()));
    }
    if (memMapTable != null) {
        memMapSection = simContextSection.addSection("Membrane Mapping For " + simContext.getName(), simContextSection.numberDepth() + 1);
        memMapSection.add(memMapTable);
    }
    int[] widths = { 1, 1, 1, 5, 8 };
    Table electTable = null;
    ElectricalStimulus[] electricalStimuli = simContext.getElectricalStimuli();
    for (int j = 0; j < electricalStimuli.length; j++) {
        if (j == 0) {
            electTable = getTable(5, 100, 1, 3, 3);
            electTable.addCell(createCell("Electrical Mapping - Electrical Stimulus", getBold(DEF_HEADER_FONT_SIZE), 5, 1, Element.ALIGN_CENTER, true));
            electTable.addCell(createHeaderCell("Stimulus Name", getBold(), 1));
            electTable.addCell(createHeaderCell("Current Name", getBold(), 1));
            electTable.addCell(createHeaderCell("Clamp Type", getBold(), 1));
            electTable.addCell(createHeaderCell("Voltage/Current Density", getBold(), 1));
            electTable.addCell(createHeaderCell("Clamp Device", getBold(), 1));
            electTable.endHeaders();
        }
        String stimName = electricalStimuli[j].getName();
        String currName = "";
        String clampType = "", expStr = "";
        Expression tempExp = null;
        VCUnitDefinition tempUnit = null;
        if (electricalStimuli[j] instanceof CurrentDensityClampStimulus) {
            CurrentDensityClampStimulus stimulus = (CurrentDensityClampStimulus) electricalStimuli[j];
            LocalParameter currentDensityParameter = stimulus.getCurrentDensityParameter();
            tempExp = currentDensityParameter.getExpression();
            tempUnit = currentDensityParameter.getUnitDefinition();
            clampType = "Current Density (deprecated)";
        } else if (electricalStimuli[j] instanceof TotalCurrentClampStimulus) {
            TotalCurrentClampStimulus stimulus = (TotalCurrentClampStimulus) electricalStimuli[j];
            LocalParameter totalCurrentParameter = stimulus.getCurrentParameter();
            tempExp = totalCurrentParameter.getExpression();
            tempUnit = totalCurrentParameter.getUnitDefinition();
            clampType = "Current";
        } else if (electricalStimuli[j] instanceof VoltageClampStimulus) {
            VoltageClampStimulus stimulus = (VoltageClampStimulus) electricalStimuli[j];
            Parameter voltageParameter = stimulus.getVoltageParameter();
            tempExp = voltageParameter.getExpression();
            tempUnit = voltageParameter.getUnitDefinition();
            clampType = "Voltage";
        }
        if (tempExp != null) {
            expStr = tempExp.infix();
            if (tempUnit != null) {
                expStr += "   " + tempUnit.getSymbolUnicode();
            }
        }
        electTable.addCell(createCell(stimName, getFont()));
        electTable.addCell(createCell(currName, getFont()));
        electTable.addCell(createCell(clampType, getFont()));
        electTable.addCell(createCell(expStr, getFont()));
        // add electrode info
        Electrode electrode = electricalStimuli[j].getElectrode();
        if (electrode == null) {
            electTable.addCell(createCell("N/A", getFont()));
        } else {
            Coordinate c = electrode.getPosition();
            String location = c.getX() + ", " + c.getY() + ", " + c.getZ();
            String featureName = electrode.getFeature().getName();
            electTable.addCell(createCell("(" + location + ") in " + featureName, getFont()));
        }
    }
    if (electTable != null) {
        if (memMapSection == null) {
            memMapSection = simContextSection.addSection("Membrane Mapping For " + simContext.getName(), 1);
        }
        electTable.setWidths(widths);
        memMapSection.add(electTable);
    }
    // add temperature
    Table tempTable = getTable(1, 75, 1, 3, 3);
    tempTable.setAlignment(Table.ALIGN_LEFT);
    tempTable.addCell(createCell("Temperature: " + simContext.getTemperatureKelvin() + " K", getFont()));
    if (memMapSection != null) {
        memMapSection.add(tempTable);
    }
}
Also used : MembraneMapping(cbit.vcell.mapping.MembraneMapping) Table(com.lowagie.text.Table) Electrode(cbit.vcell.mapping.Electrode) CurrentDensityClampStimulus(cbit.vcell.mapping.CurrentDensityClampStimulus) Section(com.lowagie.text.Section) StructureMapping(cbit.vcell.mapping.StructureMapping) TotalCurrentClampStimulus(cbit.vcell.mapping.TotalCurrentClampStimulus) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) ElectricalStimulus(cbit.vcell.mapping.ElectricalStimulus) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) FeatureMapping(cbit.vcell.mapping.FeatureMapping) Expression(cbit.vcell.parser.Expression) Coordinate(org.vcell.util.Coordinate) VoltageClampStimulus(cbit.vcell.mapping.VoltageClampStimulus) Parameter(cbit.vcell.model.Parameter) SpeciesContextSpecParameter(cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) GeometryContext(cbit.vcell.mapping.GeometryContext)

Example 5 with ElectricalStimulus

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

the class ElectricalCircuitGraph method getCircuitGraph.

/**
 * Insert the method's description here.
 * Creation date: (2/19/2002 11:24:04 AM)
 * @return cbit.vcell.mapping.potential.Graph
 * @param simContext cbit.vcell.mapping.SimulationContext
 */
public static Graph getCircuitGraph(SimulationContext simContext, AbstractMathMapping mathMapping) throws ExpressionException {
    Graph graph = new Graph();
    Model model = simContext.getModel();
    // 
    // add nodes to the graph (one for each Feature)
    // 
    Structure[] structures = model.getStructures();
    for (int i = 0; i < structures.length; i++) {
        if (structures[i] instanceof Feature) {
            graph.addNode(new Node(structures[i].getName(), structures[i]));
        }
    }
    // 
    // add edges for all current clamp electrodes (always have dependent voltages)
    // 
    ElectricalStimulus[] stimuli = simContext.getElectricalStimuli();
    Electrode groundElectrode = simContext.getGroundElectrode();
    for (int i = 0; i < stimuli.length; i++) {
        ElectricalStimulus stimulus = stimuli[i];
        // 
        // get electrodes
        // 
        Electrode probeElectrode = stimulus.getElectrode();
        if (probeElectrode == null) {
            throw new RuntimeException("null electrode for electrical stimulus");
        }
        if (groundElectrode == null) {
            throw new RuntimeException("null ground electrode for electrical stimulus");
        }
        // if (!membraneMapping.getResolved()){
        Node groundNode = graph.getNode(groundElectrode.getFeature().getName());
        Node probeNode = graph.getNode(probeElectrode.getFeature().getName());
        if (stimulus instanceof CurrentDensityClampStimulus) {
            CurrentDensityClampStimulus ccStimulus = (CurrentDensityClampStimulus) stimulus;
            ElectricalDevice device = new CurrentClampElectricalDevice(ccStimulus, mathMapping);
            Edge edge = new Edge(probeNode, groundNode, device);
            graph.addEdge(edge);
        } else if (stimulus instanceof TotalCurrentClampStimulus) {
            TotalCurrentClampStimulus ccStimulus = (TotalCurrentClampStimulus) stimulus;
            ElectricalDevice device = new CurrentClampElectricalDevice(ccStimulus, mathMapping);
            Edge edge = new Edge(probeNode, groundNode, device);
            graph.addEdge(edge);
        }
    // }
    }
    // 
    // add edges for all membranes
    // 
    ElectricalTopology electricalTopology = simContext.getModel().getElectricalTopology();
    for (int i = 0; i < structures.length; i++) {
        if (structures[i] instanceof Membrane) {
            Membrane membrane = (Membrane) structures[i];
            MembraneMapping membraneMapping = (MembraneMapping) simContext.getGeometryContext().getStructureMapping(membrane);
            Feature positiveFeature = electricalTopology.getPositiveFeature(membrane);
            Feature negativeFeature = electricalTopology.getNegativeFeature(membrane);
            if (positiveFeature != null && negativeFeature != null) {
                Node insideNode = graph.getNode(positiveFeature.getName());
                Node outsideNode = graph.getNode(negativeFeature.getName());
                // 
                // getTotalMembraneCurrent() already converts to "outwardCurrent" so that same convention as voltage
                // 
                Expression currentSource = getTotalMembraneCurrent(simContext, membrane, mathMapping);
                MembraneElectricalDevice device = new MembraneElectricalDevice(membraneMapping, mathMapping);
                device.getParameterFromRole(ElectricalDevice.ROLE_TransmembraneCurrent).setExpression(currentSource);
                Edge edge = new Edge(insideNode, outsideNode, device);
                graph.addEdge(edge);
            }
        }
    }
    // 
    for (int i = 0; i < stimuli.length; i++) {
        ElectricalStimulus stimulus = stimuli[i];
        // 
        // get electrodes
        // 
        Electrode probeElectrode = stimulus.getElectrode();
        if (probeElectrode == null) {
            throw new RuntimeException("null electrode for electrical stimulus");
        }
        if (groundElectrode == null) {
            throw new RuntimeException("null ground electrode for electrical stimulus");
        }
        // if (!membraneMapping.getResolved()){
        Node groundNode = graph.getNode(groundElectrode.getFeature().getName());
        Node probeNode = graph.getNode(probeElectrode.getFeature().getName());
        if (stimulus instanceof VoltageClampStimulus) {
            VoltageClampStimulus vcStimulus = (VoltageClampStimulus) stimulus;
            ElectricalDevice device = new VoltageClampElectricalDevice(vcStimulus, mathMapping);
            Edge edge = new Edge(probeNode, groundNode, device);
            graph.addEdge(edge);
        }
    // }
    }
    // System.out.println(graph);
    return graph;
}
Also used : MembraneMapping(cbit.vcell.mapping.MembraneMapping) Electrode(cbit.vcell.mapping.Electrode) Node(cbit.util.graph.Node) ElectricalTopology(cbit.vcell.model.Model.ElectricalTopology) CurrentDensityClampStimulus(cbit.vcell.mapping.CurrentDensityClampStimulus) Feature(cbit.vcell.model.Feature) TotalCurrentClampStimulus(cbit.vcell.mapping.TotalCurrentClampStimulus) ElectricalStimulus(cbit.vcell.mapping.ElectricalStimulus) Graph(cbit.util.graph.Graph) Expression(cbit.vcell.parser.Expression) VoltageClampStimulus(cbit.vcell.mapping.VoltageClampStimulus) Model(cbit.vcell.model.Model) Membrane(cbit.vcell.model.Membrane) Structure(cbit.vcell.model.Structure) Edge(cbit.util.graph.Edge)

Aggregations

ElectricalStimulus (cbit.vcell.mapping.ElectricalStimulus)15 Electrode (cbit.vcell.mapping.Electrode)8 Expression (cbit.vcell.parser.Expression)8 StructureMapping (cbit.vcell.mapping.StructureMapping)7 CurrentDensityClampStimulus (cbit.vcell.mapping.CurrentDensityClampStimulus)6 SimulationContext (cbit.vcell.mapping.SimulationContext)6 TotalCurrentClampStimulus (cbit.vcell.mapping.TotalCurrentClampStimulus)6 VoltageClampStimulus (cbit.vcell.mapping.VoltageClampStimulus)6 Structure (cbit.vcell.model.Structure)6 LocalParameter (cbit.vcell.mapping.ParameterContext.LocalParameter)5 Feature (cbit.vcell.model.Feature)5 Model (cbit.vcell.model.Model)5 MembraneMapping (cbit.vcell.mapping.MembraneMapping)4 SpeciesContextSpec (cbit.vcell.mapping.SpeciesContextSpec)4 SpatialProcess (cbit.vcell.mapping.spatial.processes.SpatialProcess)4 Parameter (cbit.vcell.model.Parameter)4 ProxyParameter (cbit.vcell.model.ProxyParameter)4 ExpressionException (cbit.vcell.parser.ExpressionException)4 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)4 PropertyVetoException (java.beans.PropertyVetoException)4