use of org.vcell.util.Issue in project vcell by virtualcell.
the class SpeciesContextSpec method gatherIssues.
/**
* Insert the method's description here.
* Creation date: (11/1/2005 10:03:46 AM)
* @param issueVector java.util.Vector
*/
public void gatherIssues(IssueContext issueContext, List<Issue> issueVector) {
issueContext = issueContext.newChildContext(ContextType.SpeciesContextSpec, this);
//
for (int i = 0; i < fieldParameters.length; i++) {
RealInterval simpleBounds = parameterBounds[fieldParameters[i].getRole()];
if (simpleBounds != null) {
String parmName = fieldParameters[i].getNameScope().getName() + "." + fieldParameters[i].getName();
issueVector.add(new SimpleBoundsIssue(fieldParameters[i], issueContext, simpleBounds, "parameter " + parmName + ": must be within " + simpleBounds.toString()));
}
}
if (bForceContinuous && !bConstant && getSimulationContext().isStoch() && (getSimulationContext().getGeometry().getDimension() > 0)) {
// if it's particle or constant we're good
SpeciesContext sc = getSpeciesContext();
ReactionContext rc = getSimulationContext().getReactionContext();
ReactionSpec[] rsArray = rc.getReactionSpecs();
for (ReactionSpec rs : rsArray) {
if (!rs.isExcluded()) {
// we only care about reactions which are not excluded
// true if "this" is part of current reaction
boolean iAmParticipant = false;
// true if current reaction has at least a particle participant
boolean haveParticle = false;
ReactionStep step = rs.getReactionStep();
for (ReactionParticipant p : step.getReactionParticipants()) {
if (p instanceof Product || p instanceof Reactant) {
SpeciesContextSpec candidate = rc.getSpeciesContextSpec(p.getSpeciesContext());
if (candidate == this) {
iAmParticipant = true;
} else if (!candidate.isForceContinuous() && !candidate.isConstant()) {
haveParticle = true;
}
}
}
if (iAmParticipant && haveParticle) {
String msg = "Continuous Species won't conserve mass in particle reaction " + rs.getReactionStep().getName() + ".";
String tip = "Mass conservation for reactions of binding between discrete and continuous species is handled approximately. <br>" + "To avoid any algorithmic approximation, which may produce undesired results, the user is advised to indicate <br>" + "the continuous species in those reactions as modifiers (i.e. 'catalysts') in the physiology.";
issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.SEVERITY_WARNING));
// we issue warning as soon as we found the first reaction which satisfies criteria
break;
}
}
}
}
if (!bForceContinuous && bConstant) {
if (getSimulationContext().isStoch() && (getSimulationContext().getGeometry().getDimension() > 0)) {
String msg = "Clamped Species must be continuous rather than particles.";
String tip = "If choose 'clamped', must also choose 'forceContinuous'";
issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.SEVERITY_ERROR));
}
}
if (bForceContinuous && !bConstant) {
if (getSimulationContext().isStoch() && (getSimulationContext().getGeometry().getDimension() == 0)) {
String msg = "Non-constant species is forced continuous, not supported for nonspatial stochastic applications.";
issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_ERROR));
}
}
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class StructureMapping method detectMappingConflictIssues.
private static void detectMappingConflictIssues(IssueContext issueContext, List<Issue> issueVector, StructureMapping ours) {
if (ours.getGeometryClass() == null) {
return;
}
final String ourStructureName = ours.getStructure().getName();
final String ourStructureTypeName = ours.getStructure().getTypeName();
final String ourSubdomainName = ours.getGeometryClass().getName();
SimulationContext sc = ours.simulationContext;
// list of incompatible structures mapped to the same subdomain, correctly built but not used
String incompatibilityList = "";
boolean incompatibilityFound = false;
StructureMapping[] structureMappings = sc.getGeometryContext().getStructureMappings();
for (StructureMapping theirs : structureMappings) {
if (ours == theirs) {
// don't compare ours with itself
continue;
}
if (theirs.getGeometryClass() == null) {
// 'theirs' is unmapped but some others may be, keep looking
continue;
}
final String theirSubdomainName = theirs.getGeometryClass().getName();
if (!ourSubdomainName.equals(theirSubdomainName)) {
// we don't care if mapped to another subdomain
continue;
}
String incompatibleStructure = findMappingBoundaryConflict(ours, theirs);
if (incompatibleStructure != null) {
if (incompatibilityFound) {
incompatibilityList += ", ";
}
incompatibilityList += incompatibleStructure;
incompatibilityFound = true;
}
}
if (!incompatibilityList.isEmpty()) {
// TODO: modify StructureMappingTableRenderer to customize the way issues are being rendered
String message = "Subdomain '" + ourSubdomainName + "' boundary conditions (e.g. for X-, X+...) must match.";
String tooltip = "Can't mix Flux and Value on the same column (e.g. X-, X+...) for multiple Structures mapped to the same Subdomain.";
issueVector.add(new Issue(ours, issueContext, IssueCategory.SubVolumeVerificationError, message, tooltip, Issue.Severity.ERROR));
}
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class SurfaceRegionObject method gatherIssues.
@Override
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
if (simulationContext.getGeometry().getGeometrySurfaceDescription() != null) {
GeometricRegion[] regions = simulationContext.getGeometry().getGeometrySurfaceDescription().getGeometricRegions();
boolean bFound = false;
if (regions != null) {
for (GeometricRegion region : regions) {
if (region instanceof SurfaceGeometricRegion) {
SurfaceGeometricRegion sr = (SurfaceGeometricRegion) region;
if (sr.getAdjacentGeometricRegions() != null && sr.getAdjacentGeometricRegions().length == 2) {
VolumeGeometricRegion vr1 = (VolumeGeometricRegion) sr.getAdjacentGeometricRegions()[0];
VolumeGeometricRegion vr2 = (VolumeGeometricRegion) sr.getAdjacentGeometricRegions()[1];
if (vr1.getSubVolume() == insideSubVolume && vr1.getRegionID() == insideRegionID && vr2.getSubVolume() == outsideSubVolume && vr2.getRegionID() == outsideRegionID) {
bFound = true;
}
if (vr1.getSubVolume() == outsideSubVolume && vr1.getRegionID() == outsideRegionID && vr2.getSubVolume() == insideSubVolume && vr2.getRegionID() == insideRegionID) {
bFound = true;
}
}
}
}
}
if (!bFound) {
issueList.add(new Issue(this, issueContext, IssueCategory.Identifiers, "could not find corresponding surface region in geometry", Issue.Severity.ERROR));
}
}
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class MathMapping_4_8 method getIdentifierSubstitutions.
/**
* Substitutes appropriate variables for speciesContext bindings
*
* @return cbit.vcell.parser.Expression
* @param origExp cbit.vcell.parser.Expression
* @param structureMapping cbit.vcell.mapping.StructureMapping
*/
protected Expression getIdentifierSubstitutions(Expression origExp, VCUnitDefinition desiredExpUnitDef, StructureMapping structureMapping) throws ExpressionException, MappingException {
String[] symbols = origExp.getSymbols();
if (symbols == null) {
return origExp;
}
VCUnitDefinition expUnitDef = null;
try {
VCUnitEvaluator unitEvaluator = new VCUnitEvaluator(simContext.getModel().getUnitSystem());
expUnitDef = unitEvaluator.getUnitDefinition(origExp);
if (desiredExpUnitDef == null) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println("...........exp='" + expStr + "', desiredUnits are null");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[null], observed=[" + expUnitDef.getSymbol() + "]", Issue.SEVERITY_WARNING));
} else if (expUnitDef == null) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println("...........exp='" + expStr + "', evaluated Units are null");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + desiredExpUnitDef.getSymbol() + "], observed=[null]", Issue.SEVERITY_WARNING));
} else if (desiredExpUnitDef.isTBD()) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println("...........exp='" + expStr + "', desiredUnits are [" + desiredExpUnitDef.getSymbol() + "] and expression units are [" + expUnitDef.getSymbol() + "]");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + desiredExpUnitDef.getSymbol() + "], observed=[" + expUnitDef.getSymbol() + "] for exp = " + expStr, Issue.SEVERITY_WARNING));
} else if (!desiredExpUnitDef.isEquivalent(expUnitDef) && !expUnitDef.isTBD()) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println("...........exp='" + expStr + "', desiredUnits are [" + desiredExpUnitDef.getSymbol() + "] and expression units are [" + expUnitDef.getSymbol() + "]");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + desiredExpUnitDef.getSymbol() + "], observed=[" + expUnitDef.getSymbol() + "] for exp = " + expStr, Issue.SEVERITY_WARNING));
}
} catch (VCUnitException e) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println(".........exp='" + expStr + "' exception='" + e.getMessage() + "'");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + ((desiredExpUnitDef != null) ? (desiredExpUnitDef.getSymbol()) : ("null")) + "], exception=" + e.getMessage(), Issue.SEVERITY_WARNING));
} catch (ExpressionException e) {
String expStr = origExp.renameBoundSymbols(getNameScope()).infix();
System.out.println(".........exp='" + expStr + "' exception='" + e.getMessage() + "'");
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + ((desiredExpUnitDef != null) ? (desiredExpUnitDef.getSymbol()) : ("null")) + "], exception=" + e.getMessage(), Issue.SEVERITY_WARNING));
} catch (Exception e) {
e.printStackTrace(System.out);
localIssueList.add(new Issue(origExp, issueContext, IssueCategory.Units, "expected=[" + ((desiredExpUnitDef != null) ? (desiredExpUnitDef.getSymbol()) : ("null")) + "], exception=" + e.getMessage(), Issue.SEVERITY_WARNING));
}
Expression newExp = new Expression(origExp);
for (int i = 0; i < symbols.length; i++) {
SymbolTableEntry ste = origExp.getSymbolBinding(symbols[i]);
if (ste == null) {
throw new ExpressionBindingException("symbol '" + symbols[i] + "' not bound");
// ste = simContext.getGeometryContext().getModel().getSpeciesContext(symbols[i]);
}
if (ste != null) {
String newName = getMathSymbol(ste, structureMapping);
if (!newName.equals(symbols[i])) {
newExp.substituteInPlace(new Expression(symbols[i]), new Expression(newName));
}
}
}
return newExp;
}
use of org.vcell.util.Issue in project vcell by virtualcell.
the class GeometryContext method gatherIssues.
/**
* Insert the method's description here.
* Creation date: (11/1/2005 9:48:55 AM)
* @param issueList java.util.Vector
*/
public void gatherIssues(IssueContext issueContext, List<Issue> issueList) {
issueContext = issueContext.newChildContext(ContextType.Geometry, getGeometry());
GeometrySpec geometrySpec = getGeometry().getGeometrySpec();
if (geometrySpec != null) {
geometrySpec.gatherIssues(issueContext, getGeometry(), issueList);
}
for (int i = 0; fieldStructureMappings != null && i < fieldStructureMappings.length; i++) {
fieldStructureMappings[i].gatherIssues(issueContext, issueList);
}
for (GeometryClass gc : fieldGeometry.getGeometryClasses()) {
Structure[] structuresFromGeometryClass = getStructuresFromGeometryClass(gc);
if (structuresFromGeometryClass == null || structuresFromGeometryClass.length == 0) {
UnmappedGeometryClass unmappedGeometryClass = new UnmappedGeometryClass(gc);
Issue issue = new Issue(unmappedGeometryClass, issueContext, IssueCategory.GeometryClassNotMapped, "Subdomain '" + gc.getName() + "' is not mapped to any physiological structure.", Issue.SEVERITY_WARNING);
issueList.add(issue);
}
}
if (getSimulationContext().isStoch() && getGeometry().getDimension() != 0 && getGeometry().getDimension() != 3) {
Issue issue = new Issue(this, issueContext, IssueCategory.Smoldyn_Geometry_3DWarning, "VCell spatial stochastic models only support 3D geometry.", Issue.SEVERITY_ERROR);
issueList.add(issue);
}
}
Aggregations