|
18 | 18 | pytest.param(
|
19 | 19 | {
|
20 | 20 | "multiplicity": np.array([1, 2, 3, 2]),
|
21 |
| - "volume": np.array( |
| 21 | + "water mass": np.array( |
22 | 22 | [
|
23 |
| - 1 * si.mm**3, |
24 |
| - 0.1 * si.mm**3, |
25 |
| - 1 * si.mm**3, |
26 |
| - 0.05 * si.mm**3, |
| 23 | + 1 * si.mg, |
| 24 | + 0.1 * si.mg, |
| 25 | + 1 * si.mg, |
| 26 | + 0.05 * si.mg, |
27 | 27 | ]
|
28 | 28 | ),
|
29 |
| - "rho_w": 1000, # TODO #798 - we plan to use masses instead of volumes soon |
30 | 29 | },
|
31 |
| - id="", |
32 | 30 | ),
|
33 | 31 | ),
|
34 | 32 | )
|
35 | 33 | def params_fixture(request):
|
36 | 34 | return request.param
|
37 | 35 |
|
38 | 36 |
|
39 |
| -def test_init_to_terminal_velocity(params, backend_instance): |
40 |
| - """ |
41 |
| - Fall momenta correctly initialized to the terminal velocity * mass. |
42 |
| - """ |
43 |
| - env = Box(dt=1, dv=1) |
44 |
| - builder = Builder( |
45 |
| - n_sd=len(params["multiplicity"]), backend=backend_instance, environment=env |
46 |
| - ) |
47 |
| - builder.request_attribute("terminal velocity") |
48 |
| - particulator = builder.build( |
49 |
| - attributes={"multiplicity": params["multiplicity"], "volume": params["volume"]}, |
50 |
| - products=(), |
51 |
| - ) |
52 |
| - |
53 |
| - terminal_momentum = ( |
54 |
| - particulator.attributes["terminal velocity"].to_ndarray() |
55 |
| - * params["volume"] |
56 |
| - * params["rho_w"] |
57 |
| - ) |
| 37 | +class TestInitFallMomenta: |
| 38 | + @staticmethod |
| 39 | + def test_init_to_terminal_velocity(params, backend_instance): |
| 40 | + """ |
| 41 | + Fall momenta correctly initialized to the terminal velocity * mass. |
| 42 | + """ |
| 43 | + env = Box(dt=1, dv=1) |
| 44 | + builder = Builder( |
| 45 | + n_sd=len(params["multiplicity"]), backend=backend_instance, environment=env |
| 46 | + ) |
| 47 | + builder.request_attribute("terminal velocity") |
| 48 | + particulator = builder.build( |
| 49 | + attributes={ |
| 50 | + "multiplicity": params["multiplicity"], |
| 51 | + "water mass": params["water mass"], |
| 52 | + }, |
| 53 | + products=(), |
| 54 | + ) |
58 | 55 |
|
59 |
| - assert np.allclose( |
60 |
| - init_fall_momenta(params["volume"], params["rho_w"]), terminal_momentum |
61 |
| - ) |
| 56 | + terminal_momentum = ( |
| 57 | + particulator.attributes["terminal velocity"].to_ndarray() |
| 58 | + * params["water mass"] |
| 59 | + ) |
62 | 60 |
|
| 61 | + assert np.allclose(init_fall_momenta(params["water mass"]), terminal_momentum) |
63 | 62 |
|
64 |
| -def test_init_to_zero(params): |
65 |
| - """ |
66 |
| - Fall momenta correctly initialized to zero. |
67 |
| - """ |
| 63 | + @staticmethod |
| 64 | + def test_init_to_zero(params): |
| 65 | + """ |
| 66 | + Fall momenta correctly initialized to zero. |
| 67 | + """ |
68 | 68 |
|
69 |
| - fall_momenta = init_fall_momenta(params["volume"], params["rho_w"], zero=True) |
| 69 | + fall_momenta = init_fall_momenta(params["water mass"], zero=True) |
70 | 70 |
|
71 |
| - assert (fall_momenta == np.zeros_like(fall_momenta)).all() |
| 71 | + assert (fall_momenta == np.zeros_like(fall_momenta)).all() |
0 commit comments