コード例 #1
0
    private void Start()
    {
        var g = 9.81;
        var k = 0.000007757;
        var m = 0.00007;

        _numericalSimulation = GetSimulation();
        _numericalSimulation.Setup(0.0, 0.0, _epsilon);
        _numericalSimulation.SetupYDot(f_y_t: (double y, double t) => (g - k / m * y * y));
    }
コード例 #2
0
    private void Start()
    {
        // get initial state
        var initialTheta1 = _doublePendulum.Theta_1;
        var initialTheta2 = _doublePendulum.Theta_2;

        _l_1 = _doublePendulum.Link1Length;
        _l_2 = _doublePendulum.Link2Length;

        _m_1 = _doublePendulum.Mass1;
        _m_2 = _doublePendulum.Mass2;

        _NumericalSimLambda1 = GetNumericalSimulator();
        _NumericalSimLambda1.Setup(t_0: 0.0, y_0: 0.0, epsilon: _epsilon);

        _NumericalSimuLambda2 = GetNumericalSimulator();
        _NumericalSimuLambda2.Setup(t_0: 0.0, y_0: 0.0, epsilon: _epsilon);

        _NumericalSimTheta1 = GetNumericalSimulator();
        _NumericalSimTheta1.Setup(t_0: 0.0, y_0: initialTheta1, epsilon: _epsilon);

        _NumericalSimTheta2 = GetNumericalSimulator();
        _NumericalSimTheta2.Setup(t_0: 0.0, y_0: initialTheta2, epsilon: _epsilon);

        // eq:9

        /*
         * \dot{\lambda}_1 =
         * \frac
         * {
         *      - m_2 l_2 \dot{\lambda}_2 \cos(\theta_1 - \theta_2)
         *      - m_2 l_2 \lambda^2_2 \sin(\theta_1 - \theta_2)
         *      - g (m_1 + m_2) \sin \theta_1
         * }
         * {
         *      (m_1 + m_2) l_1
         * }
         */
        _NumericalSimLambda1.SetupYDot((double lambda1, double t) =>
                                       (-_m_2 * _l_2 * _NumericalSimuLambda2.Current_y_dot *
                                        Math.Cos(_NumericalSimTheta1.Current_y - _NumericalSimTheta2.Current_y)
                                        - _m_2 * _l_2 * _NumericalSimuLambda2.Current_y * _NumericalSimuLambda2.Current_y *
                                        Math.Sin(_NumericalSimTheta1.Current_y - _NumericalSimTheta2.Current_y)
                                        - _g * (_m_1 + _m_2) * Math.Sin(_NumericalSimTheta1.Current_y))
                                       /
                                       ((_m_1 + _m_2) * _l_1));

        // label{eq:10}
        // \dot{\theta}_1 = \lambda_1
        _NumericalSimTheta1.SetupYDot((double theta1, double t) => _NumericalSimLambda1.Current_y);

        // eq:11

        /*
         * \dot{\lambda}_2 =
         * \frac
         * {
         *      m_2 l_1 \lambda^2_1 sin(\theta_1 - \theta_2)
         *      - m_2 l_1 \dot{\lambda}_1 cos(\theta_1 - \theta_2)
         *      - m_2 g \sin \theta_2
         * }
         * {
         *      m_2 l_2
         * }
         *
         */
        _NumericalSimuLambda2.SetupYDot((double lambda2, double t) =>
                                        (_m_2 * _l_1 * _NumericalSimLambda1.Current_y * _NumericalSimLambda1.Current_y *
                                         Math.Sin(_NumericalSimTheta1.Current_y - _NumericalSimTheta2.Current_y)
                                         - _m_2 * _l_1 * _NumericalSimLambda1.Current_y_dot *
                                         Math.Cos(_NumericalSimTheta1.Current_y - _NumericalSimTheta2.Current_y)
                                         - _m_2 * _g * Math.Sin(_NumericalSimTheta2.Current_y))
                                        /
                                        (_m_2 * _l_2));

        // no label (not written about this one yet)
        // \dot{\theta}_2 = \lambda_2
        _NumericalSimTheta2.SetupYDot((double theta2, double t) => _NumericalSimuLambda2.Current_y);
    }
コード例 #3
0
 private void Start()
 {
     _numericalSimulation = GetSimulation();
     _numericalSimulation.Setup(0.0, 0.5, _epsilon);
     _numericalSimulation.SetupYDot(f_y_t: (double y, double t) => 2 * y / (1 + t));
 }