Esempio n. 1
0
def new_numba(N):
    import numba
    spec = [
        ('N', numba.int32),
        ('D', numba.float64),
        ('vz', numba.float64),
        ('k', numba.float64),
        ('Cf', numba.float64),
        ('z0', numba.float64),
        ('zf', numba.float64),
        ('h', numba.float64),
    ]
    Numba_PFR = numba.jitclass(spec)(pfr)
    jitted_pfr_model = numba.jit(model_pfr_shared_direct, nopython=True)
    numba_pfr = Numba_PFR(N)
    numba_args = setup_base(N)
    numba_args[3] = numba_pfr
    dasslcy.solve(jitted_pfr_model, *numba_args, share_res=1)
    return [jitted_pfr_model] + numba_args
Esempio n. 2
0
def test_scenario3_shared_res(scenario3):
    t, y, yp = dasslcy.solve(*scenario3, share_res=1)
    y_ref = [0.93226827, -0.36176772, -0.96384619, -2.48381292, 10.64973574]
    assert (np.all(np.isclose(y[-1], y_ref, rtol=1e-3)))
Esempio n. 3
0
def test_scenario2_shared_res(scenario2):
    t, y, yp = dasslcy.solve(*scenario2, share_res=1)
    assert (np.all(np.isclose(y[-1], [0.00673799, 0.00669256, 0.98656945])))
Esempio n. 4
0
def test_scenario1_shared_res(scenario1):
    t, y, yp = dasslcy.solve(*scenario1, share_res=1)
    assert (np.all(np.isclose(y[-1], [0.91294581, 0.40808469])))
Esempio n. 5
0
def test_scenario0_shared_res(scenario0):
    t, y, yp = dasslcy.solve(*scenario0, share_res=1)
    assert (np.isclose(y[-1], 0.1353356))
Esempio n. 6
0
        res[4] = yp[4] + 3 * y[3] * par.g / par.L**2
        ires = 0
    else:
        print("Invalid index.")
        ires = -1

    return res, ires


######################################## Solve model0 ##############################################
print('------- Solve model0  ---------- ')
# ---------------------- Integration interval with initial and final time
t0 = np.array([0.0, 1.0])
y0 = np.array([1.0])  # ---------------------- Initial condition

t, y, yp = dasslcy.solve(model0, t0, y0)  # ---#| The simplest call to dasslc,
#| with all the mandatory inputs and outputs.
#| y and yp are equally spaced in all time span
# Plot results
if has_plt:
    plt.figure(1)
    plt.subplot(211)
    plt.plot(t, y)
    plt.ylabel('y')
    plt.title('Model0 Solution')
    plt.subplot(212)
    plt.plot(t, yp)
    plt.xlabel('time')
    plt.ylabel('yp')
print('States at final time: {}'.format(y[-1, :]))
Esempio n. 7
0
def test_numba(Nfix):
    args = setup_solver_numba(Nfix)
    t, y, yp = dasslcy.solve(*args, share_res=1)
    assert(np.isclose(sum(y[-1]), 81.9599366, 1e-3))
Esempio n. 8
0
def test_py_cython_typed(Nfix):
    args = setup_solver_typed_cython(Nfix)
    t, y, yp = dasslcy.solve(*args, share_res=1)
    assert(np.isclose(sum(y[-1]), 81.9599366, 1e-3))
Esempio n. 9
0
def test_py_shared_broadcast(Nfix):
    args = setup_solver_shared_np_broadcast(Nfix)
    t, y, yp = dasslcy.solve(*args, share_res=1)
    assert(np.isclose(sum(y[-1]), 81.9599366, 1e-3))
Esempio n. 10
0
def test_py(Nfix):
    args = setup_solver_regular(Nfix)
    t, y, yp = dasslcy.solve(*args)
    assert(np.isclose(sum(y[-1]), 81.9599366, 1e-3))
Esempio n. 11
0
def run_solver_numba(N):
    args = setup_solver_numba(N)
    dasslcy.solve(*args, share_res=1)
Esempio n. 12
0
def run_solver(N):
    args = setup_solver_regular(N)
    t, y, yp = dasslcy.solve(*args)
    return