Beispiel #1
0
def test_correct_dopri_integrator_name_in_generated_file(tmpfile):
    dsargs, _ = vanDerPol()
    dsargs['nobuild'] = True
    ode = Dopri_ODEsystem(dsargs)
    ode.makeLibSource(fname=tmpfile)
    with open(tmpfile) as f:
        assert 'for Dopri853 integrator' in next(f)
Beispiel #2
0
def test_correct_dopri_integrator_name_in_generated_file(tmpfile):
    dsargs, _ = vanDerPol()
    dsargs['nobuild'] = True
    ode =  Dopri_ODEsystem(dsargs)
    ode.makeLibSource(fname=tmpfile)
    with open(tmpfile) as f:
        assert 'for Dopri853 integrator' in next(f)
Beispiel #3
0
def test_c_funcspec_with_loop():
    args = {
        'name': 'fs_with_loop',
        'varspecs': {
            'z[i]': 'for(i, 1, 6, t + [i]/2)',  # FIXME: using 't**[i]' or 't^[i]' here results in RuntimeError
        },
        'nobuild': True,
    }

    # XXX: FuncSpec doesn't support 'for' loop directly
    fs = Dopri_ODEsystem(args).funcspec
    assert fs.spec[0].split('\n') == [
        'void vfieldfunc(unsigned n_, unsigned np_, double t, double *Y_, double *p_, double *f_, unsigned wkn_, double *wk_, unsigned xvn_, double *xv_){',
        '',
        'f_[0] = t+1/2;',
        'f_[1] = t+2/2;',
        'f_[2] = t+3/2;',
        'f_[3] = t+4/2;',
        'f_[4] = t+5/2;',
        'f_[5] = t+6/2;',
        '',
        '}',
        '',
        '',
    ]
Beispiel #4
0
def test_dopri_event(dsargs):
    """
        Test Dopri_ODEsystem with events involving external inputs.

        Robert Clewley, September 2006.
    """

    _run_checks(Dopri_ODEsystem(dsargs))
Beispiel #5
0
def test_dopri_does_not_support_mass_matrix(tmpfile):
    dsargs = dae()
    dsargs['nobuild'] = True
    with pytest.raises(ValueError):
        ode = Dopri_ODEsystem(dsargs)
        ode.makeLibSource(fname=tmpfile)
Beispiel #6
0
def test_dopri_does_not_support_mass_matrix(tmpfile):
    dsargs = dae()
    dsargs['nobuild'] = True
    with pytest.raises(ValueError):
        ode = Dopri_ODEsystem(dsargs)
        ode.makeLibSource(fname=tmpfile)