Search in sources :

Example 1 with NormalComponent

use of cbit.vcell.math.ComputeNormalComponentEquation.NormalComponent in project vcell by virtualcell.

the class MembraneSubDomain method parse.

/*
public MembraneSubDomain(MathDescription provider, org.vcell.util.Token token, CommentStringTokenizer tokens) throws MathException, ExpressionException { 
	super("");
	setBeforeComment(token.getBeforeComment());

	insideCompartment = provider.getCompartmentSubDomain(tokens.nextToken());
	if (insideCompartment == null){
		throw new MathFormatException("defined membrane subdomain without a corresponding inside volume subdomain first");
	}	
	outsideCompartment = provider.getCompartmentSubDomain(tokens.nextToken());
	if (outsideCompartment == null){
		throw new MathFormatException("defined membrane subdomain without a corresponding outside volume subdomain first");
	}	
	name = SurfaceClass.createName(insideCompartment.getName(), outsideCompartment.getName());
	parseBlock(provider,tokens);
}
*/
@Override
protected void parse(MathDescription mathDesc, String tokenString, CommentStringTokenizer tokens) throws MathException, ExpressionException {
    if (tokenString.equalsIgnoreCase(VCML.OdeEquation)) {
        tokenString = tokens.nextToken();
        Variable var = mathDesc.getVariable(tokenString);
        if (var == null) {
            throw new MathFormatException("variable " + tokenString + " not defined");
        }
        if (!(var instanceof MemVariable)) {
            throw new MathFormatException("variable " + tokenString + " not a " + VCML.MembraneVariable);
        }
        OdeEquation ode = new OdeEquation((MemVariable) var, null, null);
        ode.read(tokens, mathDesc);
        addEquation(ode);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.BoundaryXm)) {
        String type = tokens.nextToken();
        boundaryConditionTypeXm = new BoundaryConditionType(type);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.BoundaryXp)) {
        String type = tokens.nextToken();
        boundaryConditionTypeXp = new BoundaryConditionType(type);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.BoundaryYm)) {
        String type = tokens.nextToken();
        boundaryConditionTypeYm = new BoundaryConditionType(type);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.BoundaryYp)) {
        String type = tokens.nextToken();
        boundaryConditionTypeYp = new BoundaryConditionType(type);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.BoundaryZm)) {
        String type = tokens.nextToken();
        boundaryConditionTypeZm = new BoundaryConditionType(type);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.BoundaryZp)) {
        String type = tokens.nextToken();
        boundaryConditionTypeZp = new BoundaryConditionType(type);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.PdeEquation)) {
        tokenString = tokens.nextToken();
        Variable var = mathDesc.getVariable(tokenString);
        if (var == null) {
            throw new MathFormatException("variable " + tokenString + " not defined");
        }
        if (!(var instanceof MemVariable)) {
            throw new MathFormatException("variable " + tokenString + " not a MembraneVariable");
        }
        PdeEquation pde = new PdeEquation((MemVariable) var);
        pde.read(tokens, mathDesc);
        addEquation(pde);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.MembraneRegionEquation)) {
        tokenString = tokens.nextToken();
        Variable var = mathDesc.getVariable(tokenString);
        if (var == null) {
            throw new MathFormatException("variable " + tokenString + " not defined");
        }
        if (!(var instanceof MembraneRegionVariable)) {
            throw new MathFormatException("variable " + tokenString + " not a " + VCML.MembraneRegionVariable);
        }
        MembraneRegionEquation mre = new MembraneRegionEquation((MembraneRegionVariable) var, null);
        mre.read(tokens, mathDesc);
        addEquation(mre);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.ComputeNormalX) || tokenString.equalsIgnoreCase(VCML.ComputeNormalY) || tokenString.equalsIgnoreCase(VCML.ComputeNormalZ)) {
        NormalComponent normalComponent = null;
        if (tokenString.equalsIgnoreCase(VCML.ComputeNormalX)) {
            normalComponent = NormalComponent.X;
        } else if (tokenString.equalsIgnoreCase(VCML.ComputeNormalY)) {
            normalComponent = NormalComponent.Y;
        } else if (tokenString.equalsIgnoreCase(VCML.ComputeNormalZ)) {
            normalComponent = NormalComponent.Z;
        }
        tokenString = tokens.nextToken();
        Variable var = mathDesc.getVariable(tokenString);
        if (var == null) {
            throw new MathFormatException("variable " + tokenString + " not defined");
        }
        if (!(var instanceof MemVariable)) {
            throw new MathFormatException("variable " + tokenString + " not a " + VCML.MembraneVariable);
        }
        ComputeNormalComponentEquation computeNormalComponentEquation = new ComputeNormalComponentEquation((MemVariable) var, normalComponent);
        computeNormalComponentEquation.read(tokens, mathDesc);
        addEquation(computeNormalComponentEquation);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.ParticleProperties)) {
        ParticleProperties pp = new ParticleProperties(mathDesc, tokens);
        if (pp.getVariable().getDomain().getName().equals(this.getName())) {
            addParticleProperties(pp);
        } else {
            throw new MathException("Variable (" + pp.getVariable().getName() + ") is defined in domain " + pp.getVariable().getDomain().getName() + ". \nHowever the variable particle properties of " + pp.getVariable().getName() + " is defined in domain " + this.getName() + ". \nPlease check your model.");
        }
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.ParticleJumpProcess)) {
        ParticleJumpProcess particleJumpProcess = ParticleJumpProcess.fromVCML(mathDesc, tokens);
        addParticleJumpProcess(particleJumpProcess);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.JumpCondition)) {
        tokenString = tokens.nextToken();
        Variable var = mathDesc.getVariable(tokenString);
        if (var == null) {
            throw new MathFormatException("variable " + tokenString + " not defined");
        }
        JumpCondition jump = null;
        if (var instanceof VolVariable) {
            jump = new JumpCondition((VolVariable) var);
        } else if (var instanceof VolumeRegionVariable) {
            jump = new JumpCondition((VolumeRegionVariable) var);
        } else {
            throw new MathException("variable " + tokenString + " is neither a VolumeVariable nor a VolumeRegionVariable");
        }
        jump.read(tokens, mathDesc);
        addJumpCondition(jump);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.FastSystem)) {
        FastSystem fs = new FastSystem(mathDesc);
        fs.read(tokens, mathDesc);
        setFastSystem(fs);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.VelocityX)) {
        velocityX = parseAndBind(mathDesc, tokens);
        return;
    }
    if (tokenString.equalsIgnoreCase(VCML.VelocityY)) {
        velocityY = parseAndBind(mathDesc, tokens);
        return;
    }
    if (FUTURE_VCML_SYMBOLS.containsKey(tokenString)) {
        final int numberAdditionalTokensToSkip = FUTURE_VCML_SYMBOLS.get(tokenString);
        for (int i = 0; i < numberAdditionalTokensToSkip; i++) {
            tokens.nextToken();
        }
        return;
    }
    throw new MathFormatException("unexpected identifier " + tokenString);
}
Also used : NormalComponent(cbit.vcell.math.ComputeNormalComponentEquation.NormalComponent)

Example 2 with NormalComponent

use of cbit.vcell.math.ComputeNormalComponentEquation.NormalComponent in project vcell by virtualcell.

the class XmlReader method getComputeNormal.

private ComputeNormalComponentEquation getComputeNormal(Element param, MathDescription mathDesc) throws XmlParseException {
    // get attributes
    String varname = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    // find reference in the dictionnary
    // try a MembraneRegionVariable
    MemVariable varref = (MemVariable) mathDesc.getVariable(varname);
    if (varref == null) {
        throw new XmlParseException("The reference to the Membrane variable " + varname + " could not be resolved!");
    }
    NormalComponent normalComponent = null;
    String normalComponentString = param.getAttributeValue(XMLTags.ComputeNormalComponentAttrTag);
    if (normalComponentString.equals(XMLTags.ComputeNormalComponentAttrTagValue_X)) {
        normalComponent = NormalComponent.X;
    } else if (normalComponentString.equals(XMLTags.ComputeNormalComponentAttrTagValue_Y)) {
        normalComponent = NormalComponent.Y;
    } else if (normalComponentString.equals(XMLTags.ComputeNormalComponentAttrTagValue_Z)) {
        normalComponent = NormalComponent.Z;
    }
    ComputeNormalComponentEquation computeNormal = new ComputeNormalComponentEquation(varref, normalComponent);
    return computeNormal;
}
Also used : NormalComponent(cbit.vcell.math.ComputeNormalComponentEquation.NormalComponent) MemVariable(cbit.vcell.math.MemVariable) ComputeNormalComponentEquation(cbit.vcell.math.ComputeNormalComponentEquation)

Aggregations

NormalComponent (cbit.vcell.math.ComputeNormalComponentEquation.NormalComponent)2 ComputeNormalComponentEquation (cbit.vcell.math.ComputeNormalComponentEquation)1 MemVariable (cbit.vcell.math.MemVariable)1