Examples of CTDirector


Examples of ptolemy.domains.ct.kernel.CTDirector

     @exception IllegalActionException If thrown by the supper class.
     */
    public void initialize() throws IllegalActionException {
        super.initialize();

        CTDirector dir = (CTDirector) getDirector();
        _nextSamplingTime = dir.getModelTime();

        if (_debugging) {
            _debug("Next sampling time is at " + _nextSamplingTime);
        }
    }
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     @return True.
     *  @exception IllegalActionException If the next sampling time can not be
     *  set as a breakpoint.
     */
    public boolean postfire() throws IllegalActionException {
        CTDirector director = (CTDirector) getDirector();

        if ((director.getExecutionPhase() == CTExecutionPhase.GENERATING_EVENTS_PHASE)
                && hasCurrentEvent()) {
            // register for the next event.
            _nextSamplingTime = _nextSamplingTime.add(_samplePeriod);

            if (_debugging) {
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

    /** Return half the current step size if the step crosses the threshold.
     *  Otherwise, return the current step size.
     *  @return Half of the current step size if the step is not accurate.
     */
    public double refinedStepSize() {
        CTDirector dir = (CTDirector) getDirector();

        if (!_accurate) {
            return 0.5 * dir.getCurrentStepSize();
        }

        return dir.getCurrentStepSize();
    }
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     *  step will use the initial step size.
     *  @param integrator The integrator of that calls this method.
     *  @return The initial step size.
     */
    public double integratorPredictedStepSize(CTBaseIntegrator integrator) {
        CTDirector director = (CTDirector) getContainer();
        return director.getInitialStepSize();
    }
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

        // First assume that the states will converge after this round.
        // If any integrator does not agree, the final converged status may be
        // changed via calling _voteForConverged() by that integrator.
        _setConverged(true);

        CTDirector director = (CTDirector) getContainer();
        super.fireDynamicActors();

        if (_getRoundCount() == 0) {
            _recalculatingWithTwoSteps = false;
            _firstStep = true;
            director.setModelTime(director.getModelTime().add(
                    director.getCurrentStepSize()));
        }

        if (_isConverged()) {
            // Resolved states have converged.
            // We need to recalculate the states with two steps.
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     @exception IllegalActionException If there is no director, or can not
     *  read input, or send output.
     */
    public void integratorFire(CTBaseIntegrator integrator)
            throws IllegalActionException {
        CTDirector director = (CTDirector) getContainer();
        double h = director.getCurrentStepSize();
        double tentativeState;

        if (_getRoundCount() == 0) {
            // During the first round, use the current derivative to predict
            // the states at currentModelTime + currentStepSize. The predicted
            // states are the initial guesses for fixed-point iteration.
            double f1 = integrator.getDerivative();
            tentativeState = integrator.getState() + (f1 * h);

            // Set converged to false such that the integrator will be refired
            // again to check convergence of resolved states.
            _voteForConverged(false);
        } else {
            // get the derivative at the beginning time of current integration.
            double f1 = integrator.getDerivative();

            // get predicated derivative at the end time of current integration.
            double f2 = ((DoubleToken) integrator.input.get(0)).doubleValue();

            if (!_recalculatingWithTwoSteps) {
                tentativeState = integrator.getState()
                        + ((h * (f1 + f2)) / 2.0);

                double error = Math.abs(tentativeState
                        - integrator.getTentativeState());

                if (error < director.getValueResolution()) {
                    // save resolved states for local truncation error control
                    integrator.setAuxVariables(0, tentativeState);
                    _voteForConverged(true);
                } else {
                    _voteForConverged(false);
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     @param integrator The integrator that calls this method.
     *  @return True if the local truncation error is less than the
     *  error tolerance.
     */
    public boolean integratorIsAccurate(CTBaseIntegrator integrator) {
        CTDirector director = (CTDirector) getContainer();
        double tolerance = director.getErrorTolerance();
        double[] k = integrator.getAuxVariables();
        double localError = (1.0 / 3.0)
                * Math.abs(integrator.getTentativeState() - k[0]);
        integrator.setAuxVariables(1, localError);

View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     *  </pre>
     *  @param integrator The integrator of that calls this method.
     *  @return The suggested next step by the given integrator.
     */
    public double integratorPredictedStepSize(CTBaseIntegrator integrator) {
        CTDirector director = (CTDirector) getContainer();
        double localError = (integrator.getAuxVariables())[1];
        double h = director.getCurrentStepSize();
        double tolerance = director.getErrorTolerance();
        double newh = h;

        if ((localError / tolerance) < 0.1) {
            newh = h
                    * Math.min(2, Math.pow(((3.0 * tolerance) / localError),
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     *  <i>maxIterations</i> number. Mean while, the round count is reset.
     *  @return True if the resolved states have converged.
     *  @exception IllegalActionException Not thrown in this base class.
     */
    public boolean resolveStates() throws IllegalActionException {
        CTDirector director = (CTDirector) getContainer();

        if (_getRoundCount() > director.getMaxIterations()) {
            _resetRoundCount();
            return false;
        }

        return super.resolveStates();
View Full Code Here

Examples of ptolemy.domains.ct.kernel.CTDirector

     @exception IllegalActionException If there is no director, or can not
     *  read input, or can not send output.
     */
    public void integratorFire(CTBaseIntegrator integrator)
            throws IllegalActionException {
        CTDirector director = (CTDirector) getContainer();
        double tentativeState = integrator.getState();

        if (_getRoundCount() == 0) {
            // During the first round, use the current derivative to predict
            // the states at currentModelTime + currentStepSize. The predicted
            // states are the initial guesses for fixed-point iteration.
            double f = integrator.getDerivative();
            tentativeState = tentativeState
                    + (f * (director.getCurrentStepSize()));

            // Set converged to false such that the integrator will be refired
            // again to check convergence of resolved states.
            _voteForConverged(false);
        } else {
            // Not the first round, keep iterating until resolved states
            // converge.
            double f = ((DoubleToken) integrator.input.get(0)).doubleValue();
            tentativeState = tentativeState
                    + (f * (director.getCurrentStepSize()));

            double error = Math.abs(tentativeState
                    - integrator.getTentativeState());

            if (error < director.getValueResolution()) {
                integrator.setTentativeDerivative(f);

                // Note that the FixedStepSolver sets converged to true for
                // each round by default. Therefore, we do not need to set it
                // to true again.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.