use of org.vcell.util.Issue in project vcell by virtualcell.
the class SimulationWarning method analyzeArea.
private static void analyzeArea(Simulation simulation, double timeStep, Map<MembraneSubDomain, List<DiffusionValue>> diffusionValuesMap, IssueContext issueContext, List<Issue> issueList) {
double dx = simulation.getMeshSpecification().getDx(true);
double dy = simulation.getMeshSpecification().getDy(true);
double dz = simulation.getMeshSpecification().getDz(true);
int dim = simulation.getMathDescription().getGeometry().getDimension();
if (dim < 3) {
throw new RuntimeException("suggested timestep analysis for smoldyn not implemented for " + dim + "D simulations");
}
double smallestQuadArea = Math.min(Math.min(dx * dy, dy * dz), dx * dz);
// 1/2 for quad to triangle, 1/2 for smoother surface
double averageTriangleSize = smallestQuadArea / 4;
for (Entry<MembraneSubDomain, List<DiffusionValue>> entry : diffusionValuesMap.entrySet()) {
MembraneSubDomain msd = entry.getKey();
for (DiffusionValue dv : entry.getValue()) {
double ad = averageTriangleSize / dv.value;
boolean warn = (timeStep >= ad);
if (lg.isDebugEnabled()) {
lg.debug("average area " + averageTriangleSize + " diffusion " + dv.value + " time step limit " + ad + "timeStep " + timeStep + " -> warn " + warn);
}
if (warn) {
DecimalFormat f = new DecimalFormat("0.##E0");
String limit = f.format(ad);
String m = "Solver time step " + timeStep + " may yield inaccurate results for given mesh size and diffusion coefficient of species " + dv.name + " on membrane " + msd.getName() + "; it is recommended that the time step not exceed " + limit;
Issue i = new Issue(simulation, issueContext, IssueCategory.SMOLYDN_DIFFUSION, m, m, Severity.WARNING);
issueList.add(i);
if (lg.isDebugEnabled()) {
lg.debug("Warning " + m);
}
}
}
}
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class NernstKinetics method gatherIssues.
/**
* Insert the method's description here.
* Creation date: (5/12/2004 3:26:54 PM)
* @return cbit.util.Issue[]
*/
@Override
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
super.gatherIssues(issueContext, issueList);
//
// check for correct number of reactants and products
//
int reactantCount = 0;
int productCount = 0;
ReactionParticipant[] reactionParticipants = getReactionStep().getReactionParticipants();
for (int i = 0; i < reactionParticipants.length; i++) {
if (reactionParticipants[i] instanceof Reactant) {
reactantCount++;
}
if (reactionParticipants[i] instanceof Product) {
productCount++;
}
}
if (reactantCount != 1) {
issueList.add(new Issue(getReactionStep(), issueContext, IssueCategory.KineticsApplicability, "Nernst Kinetics must have exactly one reactant", Issue.SEVERITY_ERROR));
}
if (productCount != 1) {
issueList.add(new Issue(getReactionStep(), issueContext, IssueCategory.KineticsApplicability, "Nernst Kinetics must have exactly one product", Issue.SEVERITY_WARNING));
}
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class RbmKineticLaw method gatherIssues.
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
if (rateLawType == RbmKineticLaw.RateLawType.MassAction && parameterContext.getLocalParameterFromRole(RbmKineticLaw.RbmKineticLawParameterType.MassActionForwardRate).getExpression() == null) {
issueList.add(new Issue(this, issueContext, IssueCategory.KineticsExpressionError, "Forward Rate is null", Issue.SEVERITY_ERROR));
}
issueContext = issueContext.newChildContext(ContextType.ModelProcessDynamics, this);
parameterContext.gatherIssues(issueContext, issueList, RbmKineticLawParameterType.UserDefined);
// if((reverseRate == null) && (bReversible == true)) {
// issueList.add(new Issue(this, IssueCategory.KineticsExpressionMissing, "Reverse Rate is null", Issue.SEVERITY_WARNING));
// }
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class RbmObservable method gatherIssues.
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
issueContext = issueContext.newChildContext(ContextType.RbmObservable, this);
if (name == null) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "Name of Observable is null", Issue.SEVERITY_ERROR));
} else if (name.equals("")) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "Name of Observable is empty", Issue.SEVERITY_WARNING));
} else {
if (speciesPatternList == null) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "Observable '" + name + "' Species Pattern List is null", Issue.SEVERITY_ERROR));
} else if (speciesPatternList.isEmpty()) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "Observable '" + name + "' Species Pattern List is empty", Issue.SEVERITY_WARNING));
} else {
for (SpeciesPattern sp : speciesPatternList) {
sp.checkSpeciesPattern(issueContext, issueList);
sp.gatherIssues(issueContext, issueList);
for (MolecularTypePattern mtpThis : sp.getMolecularTypePatterns()) {
checkComponentStateConsistency(issueContext, issueList, mtpThis);
}
}
}
if (type == null) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "Observable '" + name + "' Type is null", Issue.SEVERITY_ERROR));
}
}
for (SpeciesPattern sp : speciesPatternList) {
for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
String name = mtp.getMolecularType().getDisplayName().toLowerCase();
if (name.equals("trash")) {
String message = "'Trash' is a reserved NFSim keyword and it cannot be used as an observable.";
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, message, Issue.Severity.WARNING));
}
}
}
// ---------------------------------------- polymer notation restrictions
// polymer notation may only contain one species pattern and one type of molecule
boolean polymerAllowedSingle = true;
// ---------------,,---------------- molecules in trivial state (question marks for bonds and states)
boolean polymerAllowedSimple = true;
if (speciesPatternList.size() > 1) {
polymerAllowedSingle = false;
}
if (speciesPatternList.size() > 0) {
SpeciesPattern sp = speciesPatternList.get(0);
if (sp != null && !sp.getMolecularTypePatterns().isEmpty()) {
if (sp.getMolecularTypePatterns().size() > 1) {
polymerAllowedSingle = false;
} else {
MolecularTypePattern mtp = sp.getMolecularTypePatterns().get(0);
if (mtp != null) {
for (MolecularComponentPattern mcp : mtp.getComponentPatternList()) {
if (mcp.isbVisible()) {
polymerAllowedSimple = false;
break;
}
}
}
}
}
}
if (!polymerAllowedSingle && sequence != Sequence.Multimolecular) {
String message = "Polymer may only be specified for Observable containing a single Molecule.";
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, message, Issue.Severity.ERROR));
} else if (!polymerAllowedSimple && sequence != Sequence.Multimolecular) {
String message = "Polymer may only be specified for Observable with all bonds set to 'Possible' and all States set to 'Any'";
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, message, Issue.Severity.ERROR));
}
if (sequence != Sequence.Multimolecular && type == ObservableType.Molecules) {
String message = "The Polymer Observable must be of type 'Species'.";
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, message, Issue.Severity.ERROR));
}
if (name.equalsIgnoreCase("Rg3")) {
System.out.println(name);
}
for (SpeciesPattern sp : speciesPatternList) {
// we look for species patterns where the polymer notation would be more suitable
Set<String> moleculeNames = new HashSet<>();
boolean isTrivial = true;
for (MolecularTypePattern mtp : sp.getMolecularTypePatterns()) {
moleculeNames.add(mtp.getMolecularType().getDisplayName());
for (MolecularComponentPattern mcp : mtp.getComponentPatternList()) {
if (mcp.isbVisible()) {
isTrivial = false;
// we may have more than 1 sp in the observable, check them all
continue;
}
}
}
if (isTrivial && sp.getMolecularTypePatterns().size() > 1 && moleculeNames.size() == 1) {
String message = "Please use the Polymer notation (i.e. " + moleculeNames.toArray()[0] + "()>" + (sp.getMolecularTypePatterns().size() - 1) + " ) ";
message += "instead of " + sp.toString();
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, message, Issue.Severity.WARNING));
// if we find one sp that is suitable for polymer notation we stop here and don't check other sp
break;
}
}
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class RbmObservable method checkComponentStateConsistency.
public void checkComponentStateConsistency(IssueContext issueContext, List<Issue> issueList, MolecularTypePattern mtpThis) {
if (issueList == null) {
// this may be called during parsing before the model is consistent
return;
}
MolecularType mtThat = mtpThis.getMolecularType();
for (MolecularComponentPattern mcpThis : mtpThis.getComponentPatternList()) {
if (mcpThis.isImplied()) {
// continue;
}
ComponentStatePattern cspThis = mcpThis.getComponentStatePattern();
String mcNameThis = mcpThis.getMolecularComponent().getName();
if (cspThis == null && mcpThis.getMolecularComponent().getComponentStateDefinitions().size() > 0) {
// String msg = "Component pattern " + mcNameThis + " is in no State while the component has possible States defined.";
String msg = "One of the possible States must be chosen for " + MolecularComponentPattern.typeName + " " + mcNameThis + ".";
issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, null, Issue.SEVERITY_WARNING));
}
MolecularComponent[] mcThatList = mtThat.getMolecularComponents(mcNameThis);
if (mcThatList.length == 0) {
System.out.println("we already fired an issue about component missing");
// nothing to do here, we already fired an issue about component missing
continue;
} else if (mcThatList.length > 1) {
String msg = "Multiple " + MolecularComponent.typeName + "s with the same name are not yet supported.";
issueList.add(new Issue(this, mcpThis, issueContext, IssueCategory.Identifiers, msg, null, Issue.SEVERITY_ERROR));
} else {
// found exactly 1 component
MolecularComponent mcThat = mcThatList[0];
List<ComponentStateDefinition> csdListThat = mcThat.getComponentStateDefinitions();
if (csdListThat.size() == 0) {
// component has no states, we check if mcpThis has any states... it shouldn't
if (cspThis == null) {
// all is well
continue;
}
if (!cspThis.isAny() || (cspThis.getComponentStateDefinition() != null)) {
String msg = MolecularComponentPattern.typeName + " " + mcNameThis + " is in an invalid State.";
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
}
} else {
// we check if mcpThis has any of these states... it should!
if ((cspThis == null) || cspThis.isAny() || (cspThis.getComponentStateDefinition() == null)) {
// String msg = "Component pattern " + mcNameThis + " must be in an explicit State.";
// issueList.add(new Issue(this, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
} else {
String csdNameThis = cspThis.getComponentStateDefinition().getName();
if (csdNameThis.isEmpty() || (mcThat.getComponentStateDefinition(csdNameThis) == null)) {
String msg = "Invalid State " + csdNameThis + " " + MolecularComponentPattern.typeName + " " + mcNameThis;
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
}
}
}
}
}
}
Aggregations