def test_modelparams_obj(): """ Test the behavior of the `ModelParams` object Test the instantiation and attribute data for the `ModelParams object of the `bent_plume_model` module. """ # Get the ambient CTD data profile = get_profile() # Initialize the ModelParams object p = bent_plume_model.ModelParams(profile) # Check if the attributes are set correctly assert_approx_equal(p.rho_r, 1031.035855535142, significant=6) assert p.g == 9.81 assert p.Ru == 8.314510 assert p.alpha_j == 0.057 assert p.alpha_Fr == 0.544 assert p.gamma == 1.10 assert p.Fr_0 == 1.6
def test_plume_objs(): """ Test the object behavior for the `LagElement` object Test the instantiation and attribute data for the `LagElement` object of the `bent_plume_model` module. This test does many of the calculations in `Model.Simulate`, but does not perform the simulation. """ # Get the model parameters profile, X0, D, Vj, phi_0, theta_0, Sj, Tj, cj, tracers, particles, \ dt_max, sd_max = get_sim_data() p = bent_plume_model.ModelParams(profile) # Get the initial conditions for this plume t0, q0, chem_names = lmp.main_ic(profile, particles, X0, D, Vj, phi_0, theta_0, Sj, Tj, cj, tracers, p) # Create the `LagElement` object: q_local = bent_plume_model.LagElement(t0, q0, D, profile, p, particles, tracers, chem_names) # Validate the values in q_local assert q_local.t0 == t0 assert_array_almost_equal(q_local.q0, q0, decimal = 6) assert q_local.D == D for i in range(len(tracers)): assert q_local.tracers[i] == tracers[i] for i in range(len(chem_names)): assert q_local.chem_names[i] == chem_names[i] assert q_local.len == q0.shape[0] assert q_local.nchems == len(chem_names) assert q_local.np == len(particles) assert q_local.t == t0 assert_array_almost_equal(q_local.q, q0, decimal=6) assert q_local.M == q0[0] assert q_local.Se == q0[1] assert q_local.He == q0[2] assert q_local.Jx == q0[3] assert q_local.Jy == q0[4] assert q_local.Jz == q0[5] assert q_local.H == q0[6] assert q_local.x == q0[7] assert q_local.y == q0[8] assert q_local.z == q0[9] assert q_local.s == q0[10] assert_array_almost_equal(q_local.M_p[0], np.array([9.82463141e-06, 0.00000000e+00, 0.00000000e+00]), decimal=6) assert_array_almost_equal(q_local.M_p[1], np.array([14.79129693]), decimal=6) assert_approx_equal(q_local.H_p[0], 5.60670238e+00, significant=8) assert_approx_equal(q_local.H_p[1], 8.44106982e+06, significant=8) assert_array_almost_equal(q_local.t_p, np.array([0., 0.]), decimal=6) assert_array_almost_equal(q_local.X_p[0], np.array([0., 0., 0.]), decimal=6) assert_array_almost_equal(q_local.X_p[1], np.array([0., 0., 0.]), decimal=6) assert_array_almost_equal(q_local.cpe, np.array([1.73577225e-05, 0.00000000e+00, 0.00000000e+00]), decimal=6) assert_array_almost_equal(q_local.cte, np.array([4.36126913]), decimal=6) assert_approx_equal(q_local.Ta, 285.52466101019053, significant=8) assert_approx_equal(q_local.Sa, 35.52902290651307, significant=8) assert_approx_equal(q_local.Pa, 3123785.3190075322, significant=8) assert_approx_equal(q_local.ua, 0.15, significant=8) assert_approx_equal(q_local.va, 0., significant=8) assert_approx_equal(q_local.wa, 0., significant=8) assert_approx_equal(q_local.rho_a, 1028.32228185795, significant=8) assert_array_almost_equal(q_local.ca_chems, np.array([0.00409269, 0., 0.]), decimal=6) assert_approx_equal(q_local.S, 35.52902290651307, significant=8) assert_approx_equal(q_local.T, 285.52466101019053, significant=8) assert_approx_equal(q_local.rho, 1028.32228185795, significant=8) assert_array_almost_equal(q_local.c_chems, np.array([0.00409269, 0., 0.]), decimal=6) assert_array_almost_equal(q_local.c_tracers, np.array([1028.32228186]), decimal=8) assert_approx_equal(q_local.u, 2.1978825486814211e-16, significant=8) assert_approx_equal(q_local.v, 0., significant=8) assert_approx_equal(q_local.w, -3.5894145972727363, significant=8) assert_approx_equal(q_local.hvel, 2.1978825486814211e-16, significant=8) assert_approx_equal(q_local.V, 3.5894145972727363, significant=8) assert_approx_equal(q_local.h, 0.060000000000000005, significant=8) assert_approx_equal(q_local.b, 0.15000000000000002, significant=8) assert_approx_equal(q_local.sin_p, -1., significant=8) assert_approx_equal(q_local.cos_p, 6.123233995736766e-17, significant=8) assert_approx_equal(q_local.sin_t, 0., significant=8) assert_approx_equal(q_local.cos_t, 1., significant=8) assert_approx_equal(q_local.phi, -1.5707963267948966, significant=8) assert_approx_equal(q_local.theta, 0., significant=8) assert_approx_equal(q_local.fb[0], 2.29871281e-01, significant=8) assert_approx_equal(q_local.fb[1], 2.46294355e+03, significant=8) assert_array_almost_equal(q_local.mp, np.array([9.82463141e-06, 1.47912969e+01]), decimal=6) assert_array_almost_equal(q_local.x_p, np.array([[0., 0., 300.],[0., 0., 300.]]), decimal=6) assert_array_almost_equal(q_local.t_p, np.array([ 0., 0.]), decimal=6) assert_approx_equal(q_local.Fb, 2463.1734167520308, significant=8)