Search in sources :

Example 26 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class SimulationWorkspaceModelInfo method getContextName.

/**
 * Insert the method's description here.
 * Creation date: (9/25/2005 11:04:29 AM)
 * @return java.lang.String
 */
public java.lang.String getContextName() {
    String results = null;
    if (simulationOwner instanceof MathModel) {
        MathModel mathModel = (MathModel) simulationOwner;
        results = mathModel.getName();
    } else if (simulationOwner instanceof SimulationContext) {
        SimulationContext simContext = (SimulationContext) simulationOwner;
        results = simContext.getBioModel().getName() + "::" + simContext.getName();
    }
    return results;
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) SimulationContext(cbit.vcell.mapping.SimulationContext)

Example 27 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class VCellClientDataServiceImpl method createSimulationDataSetRef.

public static SimulationDataSetRef createSimulationDataSetRef(Simulation simulation, VCDocument modelDocument, int jobIndex, boolean isLocal) {
    SimulationDataSetRef simulationDataSetReference = new SimulationDataSetRef();
    Origin origin = simulation.getMathDescription().getGeometry().getOrigin();
    Extent extent = simulation.getMathDescription().getGeometry().getExtent();
    SimulationInfo simInfo = simulation.getSimulationInfo();
    simulationDataSetReference.setSimName(simInfo.getName());
    // String simName = simInfo.getName();
    // if (jobIndex!=0){
    // simName = simName + " job#"+String.valueOf(jobIndex);
    // }
    final String modelId;
    final boolean isMathModel;
    final String modelName;
    final String simContextName;
    if (modelDocument != null) {
        modelId = modelDocument.getVersion().getVersionKey().toString();
        isMathModel = (modelDocument instanceof MathModel);
        modelName = modelDocument.getName();
        if (modelDocument instanceof BioModel && simulation.getSimulationOwner() != null) {
            simContextName = simulation.getSimulationOwner().getName();
        } else {
            simContextName = null;
        }
    } else {
        modelId = "no id";
        isMathModel = false;
        modelName = "no model";
        simContextName = null;
    }
    simulationDataSetReference.setSimId(simInfo.getAuthoritativeVCSimulationIdentifier().getSimulationKey().toString());
    simulationDataSetReference.setModelId(modelId);
    simulationDataSetReference.setUsername(simInfo.getVersion().getOwner().getName());
    simulationDataSetReference.setUserkey(simInfo.getVersion().getOwner().getID().toString());
    simulationDataSetReference.setIsMathModel(isMathModel);
    simulationDataSetReference.setJobIndex(jobIndex);
    simulationDataSetReference.setModelName(modelName);
    simulationDataSetReference.setOriginXYZ(Arrays.asList(new Double[] { origin.getX(), origin.getY(), origin.getZ() }));
    simulationDataSetReference.setExtentXYZ(Arrays.asList(new Double[] { extent.getX(), extent.getY(), extent.getZ() }));
    if (simContextName != null) {
        simulationDataSetReference.setSimulationContextName(simContextName);
    }
    simulationDataSetReference.setSimName(simInfo.getName());
    boolean movingBoundarySolver = simulation.getSolverTaskDescription().getSolverDescription().isMovingBoundarySolver();
    simulationDataSetReference.setIsTimeVaryingMesh(movingBoundarySolver);
    simulationDataSetReference.setIsLocal(isLocal);
    return simulationDataSetReference;
}
Also used : Origin(org.vcell.util.Origin) MathModel(cbit.vcell.mathmodel.MathModel) Extent(org.vcell.util.Extent) BioModel(cbit.vcell.biomodel.BioModel) SimulationDataSetRef(cbit.vcell.client.pyvcellproxy.SimulationDataSetRef) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 28 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class MathDebuggerPanel method getMathModel2.

public MathModel getMathModel2() throws PropertyVetoException {
    MathDescription mathDesc = mathDescEditor2.getMathDescription();
    if (mathDesc == null) {
        return null;
    } else {
        MathModel mathModel = new MathModel(null);
        mathModel.setName("MATH 2");
        mathModel.setMathDescription(mathDesc);
        return mathModel;
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) MathDescription(cbit.vcell.math.MathDescription)

Example 29 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class MathDebuggerPanel method main.

public static void main(java.lang.String[] args) {
    try {
        javax.swing.JFrame frame = new javax.swing.JFrame();
        MathDebuggerPanel aMathDebuggerPanel;
        aMathDebuggerPanel = new MathDebuggerPanel();
        frame.setContentPane(aMathDebuggerPanel);
        frame.setTitle("Math Descriptions Comparator");
        frame.setSize(aMathDebuggerPanel.getSize());
        frame.addWindowListener(new java.awt.event.WindowAdapter() {

            public void windowClosing(java.awt.event.WindowEvent e) {
                System.exit(0);
            }
        });
        MathModel mathModel1 = new MathModel(null);
        mathModel1.setName("math1");
        Geometry geometry1 = new Geometry("geo", 0);
        MathDescription mathDesc1 = mathModel1.getMathDescription();
        mathDesc1.setGeometry(geometry1);
        mathDesc1.addSubDomain(new CompartmentSubDomain("Compartment", CompartmentSubDomain.NON_SPATIAL_PRIORITY));
        MathModel mathModel2 = new MathModel(null);
        mathModel2.setName("math2");
        Geometry geometry2 = new Geometry("geo", 0);
        MathDescription mathDesc2 = mathModel2.getMathDescription();
        mathDesc2.setGeometry(geometry2);
        mathDesc2.addSubDomain(new CompartmentSubDomain("Compartment", CompartmentSubDomain.NON_SPATIAL_PRIORITY));
        aMathDebuggerPanel.setMathModel1(mathModel1);
        aMathDebuggerPanel.setMathModel2(mathModel2);
        frame.setSize(1500, 800);
        frame.setVisible(true);
    } catch (Throwable exception) {
        System.err.println("Exception occurred in main() of javax.swing.JPanel");
        exception.printStackTrace(System.out);
    }
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) MathDescription(cbit.vcell.math.MathDescription) Geometry(cbit.vcell.geometry.Geometry) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain)

Example 30 with MathModel

use of cbit.vcell.mathmodel.MathModel in project vcell by virtualcell.

the class MathDebuggerPanel method paste.

private void paste() throws PropertyVetoException, MathException, XmlParseException {
    String copiedText = (String) VCellTransferable.getFromClipboard(DataFlavor.stringFlavor);
    if (!copiedText.contains("BEGINMATH:") && !copiedText.contains("ENDMATH")) {
        throw new RuntimeException("Make sure each math description is enclosed with 'BEGINMATH:' and 'ENDMATH' tags for the 'Paste' operation to work.");
    }
    String[] mathStrings = copiedText.split("BEGINMATH:");
    String mathString1 = null;
    String mathString2 = null;
    for (int i = 0; i < mathStrings.length; i++) {
        mathStrings[i] = mathStrings[i].trim();
        if (mathStrings[i].trim().startsWith("MathDescription {")) {
            int endIndex = mathStrings[i].indexOf("ENDMATH");
            if (endIndex > 0) {
                if (mathString1 == null) {
                    mathString1 = mathStrings[i].substring(0, endIndex);
                } else if (mathString2 == null) {
                    mathString2 = mathStrings[i].substring(0, endIndex);
                } else {
                    throw new RuntimeException("too many math Descriptions (expecting only two)");
                }
            }
        }
    }
    if (mathString1 != null) {
        MathDescription mathDesc = MathDescription.fromEditor(getMathDescEditor1().getMathDescription(), mathString1);
        MathModel mathModel = new MathModel(null);
        mathModel.setName("Math1");
        mathModel.setMathDescription(mathDesc);
        setMathModel1(mathModel);
    }
    if (mathString2 != null) {
        MathDescription mathDesc = MathDescription.fromEditor(getMathDescEditor2().getMathDescription(), mathString2);
        MathModel mathModel = new MathModel(null);
        mathModel.setName("Math2");
        mathModel.setMathDescription(mathDesc);
        setMathModel2(mathModel);
    }
    compareTree();
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) MathDescription(cbit.vcell.math.MathDescription)

Aggregations

MathModel (cbit.vcell.mathmodel.MathModel)70 BioModel (cbit.vcell.biomodel.BioModel)26 Simulation (cbit.vcell.solver.Simulation)24 DataAccessException (org.vcell.util.DataAccessException)21 Geometry (cbit.vcell.geometry.Geometry)20 MathDescription (cbit.vcell.math.MathDescription)20 SimulationContext (cbit.vcell.mapping.SimulationContext)19 XmlParseException (cbit.vcell.xml.XmlParseException)13 MathModelInfo (org.vcell.util.document.MathModelInfo)12 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)11 UserCancelException (org.vcell.util.UserCancelException)11 VCDocument (org.vcell.util.document.VCDocument)11 XMLSource (cbit.vcell.xml.XMLSource)10 ExpressionException (cbit.vcell.parser.ExpressionException)9 File (java.io.File)9 KeyValue (org.vcell.util.document.KeyValue)8 PropertyVetoException (java.beans.PropertyVetoException)7 IOException (java.io.IOException)7 BigString (org.vcell.util.BigString)7 BioModelInfo (org.vcell.util.document.BioModelInfo)7