当前位置: 首页>>代码示例>>Java>>正文


Java Quantity类代码示例

本文整理汇总了Java中javax.measure.Quantity的典型用法代码示例。如果您正苦于以下问题:Java Quantity类的具体用法?Java Quantity怎么用?Java Quantity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Quantity类属于javax.measure包,在下文中一共展示了Quantity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateDelta

import javax.measure.Quantity; //导入依赖的package包/类
private Delta calculateDelta(ConcentrationContainer concentrationContainer) {
    ChemicalEntity currentChemicalEntity = getCurrentChemicalEntity();
    CellSection currentCellSection = getCurrentCellSection();
    final double currentConcentration = concentrationContainer.getAvailableConcentration(currentCellSection, currentChemicalEntity).getValue().doubleValue();
    // calculate entering term
    int numberOfNeighbors = 0;
    double concentration = 0;
    // traverse each neighbouring cells
    for (AutomatonNode neighbour : getCurrentNode().getNeighbours()) {
        Map<ChemicalEntity<?>, Quantity<MolarConcentration>> concentrations = neighbour.getAllConcentrationsForSection(currentCellSection);
        if (!concentrations.isEmpty()) {
            numberOfNeighbors++;
            concentration += concentrations.get(currentChemicalEntity).getValue().doubleValue();
        }
    }
    // entering amount
    final double enteringConcentration = concentration * getFeature(currentChemicalEntity, Diffusivity.class).getValue().doubleValue();
    // calculate leaving amount
    final double leavingConcentration = numberOfNeighbors * getFeature(currentChemicalEntity, Diffusivity.class).getValue().doubleValue() * currentConcentration;
    // calculate next concentration
    final double delta = enteringConcentration - leavingConcentration; //+ currentConcentration;
    // return delta
    return new Delta(currentCellSection, currentChemicalEntity, Quantities.getQuantity(delta, MOLE_PER_LITRE));
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:25,代码来源:FreeDiffusion.java

示例2: getAllConcentrationsForSection

import javax.measure.Quantity; //导入依赖的package包/类
@Override
public Map<ChemicalEntity<?>, Quantity<MolarConcentration>> getAllConcentrationsForSection(CellSection cellSection) {
    if (cellSection.equals(outerPhaseSection)) {
        return outerPhase;
    } else if (cellSection.equals(innerPhaseSection)) {
        return innerPhase;
    } else if (cellSection.equals(membrane)) {
        Map<ChemicalEntity<?>, Quantity<MolarConcentration>> concentrations = new HashMap<>();
        for (Map.Entry<ChemicalEntity<?>, Quantity<MolarConcentration>> entry : innerLayer.entrySet()) {
            concentrations.put(entry.getKey(), entry.getValue().add(outerLayer.get(entry.getKey())).divide(2.0));
        }
        return concentrations;
    } else if (cellSection.equals(membrane.getInnerLayer())) {
        return innerLayer;
    } else if (cellSection.equals(membrane.getOuterLayer())) {
        return outerLayer;
    }
    return Collections.emptyMap();
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:20,代码来源:MembraneContainer.java

示例3: shouldPerformCalciumOscillationExample

import javax.measure.Quantity; //导入依赖的package包/类
@Test
public void shouldPerformCalciumOscillationExample() {
    logger.info("Testing Dynamic Reaction Module.");
    Simulation simulation = SimulationExamples.createSimulationFromSBML();

    Species x = new Species.Builder("X").build();
    AutomatonNode node = simulation.getGraph().getNodes().iterator().next();
    logger.info("Starting simulation ...");
    Quantity<Time> currentTime;
    Quantity<Time> firstCheckpoint = Quantities.getQuantity(169.0, MILLI(SECOND));
    boolean firstCheckpointPassed = false;
    Quantity<Time> secondCheckpoint = Quantities.getQuantity(351.0, MILLI(SECOND));
    // run simulation
    while ((currentTime = simulation.getElapsedTime().to(MILLI(SECOND))).getValue().doubleValue() < secondCheckpoint.getValue().doubleValue()) {
        simulation.nextEpoch();
        if (!firstCheckpointPassed && currentTime.getValue().doubleValue() > firstCheckpoint.getValue().doubleValue()) {
            logger.info("First checkpoint reached at {}.", simulation.getElapsedTime().to(SECOND));
            assertEquals(0.2958, node.getConcentration(x).getValue().doubleValue(), 1e-4);
            firstCheckpointPassed = true;
        }
    }

    // check final values
    assertEquals(0.2975, node.getConcentration(x).getValue().doubleValue(), 1e-4);
    logger.info("Second and final checkpoint (at {}) reached successfully.", simulation.getElapsedTime().to(SECOND));
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:27,代码来源:ReactionTest.java

示例4: setUpSimulation

import javax.measure.Quantity; //导入依赖的package包/类
private Simulation setUpSimulation(int numberOfNodes, Quantity<Time> timeStep, Species species) {
    // setup rectangular graph with number of nodes
    AutomatonGraph graph = AutomatonGraphs.useStructureFrom(Graphs.buildGridGraph(
            numberOfNodes, numberOfNodes, boundingBox, false));
    // initialize species in graph with desired concentration leaving the right "half" empty
    for (AutomatonNode node : graph.getNodes()) {
        if (node.getIdentifier() % numberOfNodes < numberOfNodes / 2) {
            node.setConcentration(species, 1.0);
        } else {
            node.setConcentration(species, 0.0);
        }
    }
    // setup time step size as given
    EnvironmentalParameters.getInstance().setTimeStep(timeStep);
    // setup node distance to diameter
    EnvironmentalParameters.getInstance().setNodeSpacingToDiameter(systemDiameter, numberOfNodes);
    // setup simulation
    Simulation simulation = new Simulation();
    // add graph
    simulation.setGraph(graph);
    // add diffusion module
    simulation.getModules().add(new FreeDiffusion(simulation));
    // return complete simulation
    return simulation;
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:26,代码来源:FreeDiffusionTest.java

示例5: runSimulation

import javax.measure.Quantity; //导入依赖的package包/类
private Quantity<Time> runSimulation(Simulation simulation, int numberOfNodes, Species species) {
    // observe the node in the middle on the right
    GridCoordinateConverter converter = new GridCoordinateConverter(numberOfNodes, numberOfNodes);
    // returns the node in the middle on the right
    int observedNodeIdentifier = converter.convert(new Vector2D(numberOfNodes - 1, (numberOfNodes / 2) - 1));
    simulation.getGraph().getNode(observedNodeIdentifier).setObserved(true);
    // simulate until half life concentration has been reached
    double currentConcentration = 0.0;
    while (currentConcentration < 0.25) {
        simulation.nextEpoch();
        final Quantity<MolarConcentration> concentration = simulation.getGraph().getNode(observedNodeIdentifier).getConcentration(species);
        currentConcentration = concentration.getValue().doubleValue();
        //System.out.println("Currently "+concentration+" at "+simulation.getElapsedTime().to(MICRO(SECOND)));
    }
    logger.info("Half life time of {} reached at {}.", species.getName(), simulation.getElapsedTime().to(MICRO(SECOND)));
    return simulation.getElapsedTime().to(MICRO(SECOND));
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:18,代码来源:FreeDiffusionTest.java

示例6: NthOrderReaction

import javax.measure.Quantity; //导入依赖的package包/类
public NthOrderReaction(Simulation simulation, Quantity<Frequency> rateConstant) {
    super(simulation);
    // feature
    availableFeatures.add(RateConstant.class);
    setFeature(new RateConstant(rateConstant, FeatureOrigin.MANUALLY_ANNOTATED));
    // deltas
    addDeltaFunction(this::calculateDeltas, bioNode -> true);
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:9,代码来源:NthOrderReaction.java

示例7: calculateVelocity

import javax.measure.Quantity; //导入依赖的package包/类
public double calculateVelocity(ConcentrationContainer concentrationContainer) {
    // reaction rate for this reaction
    final Quantity<Frequency> reactionRate = getScaledFeature(RateConstant.class);
    // concentrations of substrates that influence the reaction
    double concentration = determineConcentration(concentrationContainer, ReactantRole.DECREASING);
    // calculate acceleration
    return concentration * reactionRate.getValue().doubleValue();
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:9,代码来源:NthOrderReaction.java

示例8: calculateVelocity

import javax.measure.Quantity; //导入依赖的package包/类
@Override
public double calculateVelocity(ConcentrationContainer concentrationContainer) {
    // set entity parameters
    for (Map.Entry<ChemicalEntity, String> entry : entityReference.entrySet()) {
        final Quantity<MolarConcentration> concentration = concentrationContainer.getAvailableConcentration(currentCellSection, entry.getKey());
        final String parameterName = entityReference.get(entry.getKey());
        expression.acceptValue(parameterName, concentration.getValue().doubleValue());
    }
    return expression.evaluate().getValue().doubleValue() * appliedScale;
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:11,代码来源:DynamicKineticLaw.java

示例9: calculateOuterPhaseDelta

import javax.measure.Quantity; //导入依赖的package包/类
private Delta calculateOuterPhaseDelta(ConcentrationContainer concentrationContainer) {
    // resolve required parameters
    final ChemicalEntity<?> entity = getCurrentChemicalEntity();
    final Quantity<Frequency> kIn = getFeature(entity, MembraneEntry.class);
    final Quantity<Frequency> kOut = getFeature(entity, MembraneExit.class);
    // (outer phase) outer phase = -kIn * outer phase + kOut * outer layer
    MembraneContainer membraneContainer = (MembraneContainer) concentrationContainer;
    final double value = -kIn.getValue().doubleValue() * membraneContainer.getOuterPhaseConcentration(entity).getValue().doubleValue() +
            kOut.getValue().doubleValue() * membraneContainer.getOuterMembraneLayerConcentration(entity).getValue().doubleValue();
    return new Delta(membraneContainer.getOuterPhaseSection(), entity, Quantities.getQuantity(value, MOLE_PER_LITRE));
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:12,代码来源:PassiveMembraneTransport.java

示例10: calculateOuterLayerDelta

import javax.measure.Quantity; //导入依赖的package包/类
private Delta calculateOuterLayerDelta(ConcentrationContainer concentrationContainer) {
    // resolve required parameters
    final ChemicalEntity<?> entity = getCurrentChemicalEntity();
    final Quantity<Frequency> kIn = getFeature(entity, MembraneEntry.class);
    final Quantity<Frequency> kOut = getFeature(entity, MembraneExit.class);
    final Quantity<Frequency> kFlip = getFeature(entity, MembraneFlipFlop.class);
    // (outer layer) outer layer = kIn * outer phase - (kOut + kFlip) * outer layer + kFlip * inner layer
    MembraneContainer membraneContainer = (MembraneContainer) concentrationContainer;
    final double value = kIn.getValue().doubleValue() * membraneContainer.getOuterPhaseConcentration(entity).getValue().doubleValue() -
            (kOut.getValue().doubleValue() + kFlip.getValue().doubleValue()) * membraneContainer.getOuterMembraneLayerConcentration(entity).getValue().doubleValue() +
            kFlip.getValue().doubleValue() * membraneContainer.getInnerMembraneLayerConcentration(entity).getValue().doubleValue();
    return new Delta(membraneContainer.getOuterLayerSection(), entity, Quantities.getQuantity(value, MOLE_PER_LITRE));
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:14,代码来源:PassiveMembraneTransport.java

示例11: calculateInnerLayerDelta

import javax.measure.Quantity; //导入依赖的package包/类
private Delta calculateInnerLayerDelta(ConcentrationContainer concentrationContainer) {
    // resolve required parameters
    final ChemicalEntity<?> entity = getCurrentChemicalEntity();
    final Quantity<Frequency> kIn = getFeature(entity, MembraneEntry.class);
    final Quantity<Frequency> kOut = getFeature(entity, MembraneExit.class);
    final Quantity<Frequency> kFlip = getFeature(entity, MembraneFlipFlop.class);
    // (inner layer) inner layer = kIn * inner phase - (kOut + kFlip) * inner layer + kFlip * outer layer
    MembraneContainer membraneContainer = (MembraneContainer) concentrationContainer;
    final double value = kIn.getValue().doubleValue() * membraneContainer.getInnerPhaseConcentration(entity).getValue().doubleValue() -
            (kOut.getValue().doubleValue() + kFlip.getValue().doubleValue()) * membraneContainer.getInnerMembraneLayerConcentration(entity).getValue().doubleValue() +
            kFlip.getValue().doubleValue() * membraneContainer.getOuterMembraneLayerConcentration(entity).getValue().doubleValue();
    return new Delta(membraneContainer.getInnerLayerSection(), entity, Quantities.getQuantity(value, MOLE_PER_LITRE));
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:14,代码来源:PassiveMembraneTransport.java

示例12: calculateInnerPhaseDelta

import javax.measure.Quantity; //导入依赖的package包/类
private Delta calculateInnerPhaseDelta(ConcentrationContainer concentrationContainer) {
    // resolve required parameters
    final ChemicalEntity<?> entity = getCurrentChemicalEntity();
    final Quantity<Frequency> kIn = getFeature(entity, MembraneEntry.class);
    final Quantity<Frequency> kOut = getFeature(entity, MembraneExit.class);
    // (inner phase) inner phase = -kIn * inner phase + kOut * inner layer
    MembraneContainer membraneContainer = (MembraneContainer) concentrationContainer;
    final double value = -kIn.getValue().doubleValue() * membraneContainer.getInnerPhaseConcentration(getCurrentChemicalEntity()).getValue().doubleValue() +
            kOut.getValue().doubleValue() * membraneContainer.getInnerMembraneLayerConcentration(getCurrentChemicalEntity()).getValue().doubleValue();
    return new Delta(membraneContainer.getInnerPhaseSection(), getCurrentChemicalEntity(), Quantities.getQuantity(value, MOLE_PER_LITRE));
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:12,代码来源:PassiveMembraneTransport.java

示例13: scale

import javax.measure.Quantity; //导入依赖的package包/类
@Override
public void scale(Quantity<Time> time, Quantity<Length> space) {
    // transform to specified unit
    Quantity<Frequency> scaledQuantity = getFeatureContent()
            .to(new ProductUnit<>(ONE.divide(time.getUnit())));
    // transform to specified amount
    this.scaledQuantity = scaledQuantity.multiply(time.getValue().doubleValue());
    // and half
    halfScaledQuantity = scaledQuantity.multiply(time.multiply(0.5).getValue().doubleValue());
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:11,代码来源:MembraneExit.java

示例14: rescaleReactionRate

import javax.measure.Quantity; //导入依赖的package包/类
/**
 * Scales the reaction rate for the use with cellular graph automata. The unscaled quantity is transformed to the
 * unit specified by target time and multiplied by the value of the time scale.
 *
 * @param unscaledQuantity The quantity that is to be scaled.
 * @param targetScale The required time step.
 * @return The scaled reaction rate.
 */
public static Quantity<Frequency> rescaleReactionRate(Quantity<Frequency> unscaledQuantity,
                                                      Quantity<Time> targetScale) {
    // transform to specified unit
    Quantity<Frequency> scaledQuantity = unscaledQuantity
            .to(new ProductUnit<>(ONE.divide(targetScale.getUnit())));
    // transform to specified amount
    scaledQuantity = scaledQuantity.multiply(targetScale.getValue());
    return scaledQuantity;
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:18,代码来源:UnitScaler.java

示例15: rescaleDiffusivity

import javax.measure.Quantity; //导入依赖的package包/类
/**
 * Scales the diffusivity for the use with cellular graph automata. The unscaled quantity is transformed to the
 * unit specified by target time and length scales. Further the unscaled quantity is divided by the squared length
 * scale and multiplied by the time scale.
 *
 * @param unscaledQuantity The quantity that is to be scaled.
 * @param targetTimeScale The required time step.
 * @param targetLengthScale The required spatial step.
 * @return The scaled diffusivity.
 */
public static Quantity<Diffusivity> rescaleDiffusivity(Quantity<Diffusivity> unscaledQuantity,
                                                       Quantity<Time> targetTimeScale, Quantity<Length> targetLengthScale) {
    // transform to specified unit
    Quantity<Diffusivity> scaledQuantity = unscaledQuantity
            .to(new ProductUnit<>(targetLengthScale.getUnit().pow(2).divide(targetTimeScale.getUnit())));
    // transform to specified amount
    scaledQuantity = scaledQuantity.divide(targetLengthScale.getValue()).divide(targetLengthScale.getValue())
            .multiply(targetTimeScale.getValue());
    return scaledQuantity;
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:21,代码来源:UnitScaler.java


注:本文中的javax.measure.Quantity类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。