|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | | -# Copyright 2019-2021 Jean-Luc Vay, Maxence Thevenet, Remi Lehe, Prabhat Kumar |
| 3 | +# Copyright 2019-2022 Jean-Luc Vay, Maxence Thevenet, Remi Lehe, Prabhat Kumar, Axel Huebl |
4 | 4 | # |
5 | 5 | # |
6 | 6 | # This file is part of WarpX. |
|
11 | 11 | # the script `inputs.multi.rt`. This simulates a 1D periodic plasma wave. |
12 | 12 | # The electric field in the simulation is given (in theory) by: |
13 | 13 | # $$ E_z = \epsilon \,\frac{m_e c^2 k_z}{q_e}\sin(k_z z)\sin( \omega_p t)$$ |
| 14 | +import os |
14 | 15 | import re |
15 | 16 | import sys |
16 | 17 |
|
|
21 | 22 | import yt |
22 | 23 |
|
23 | 24 | yt.funcs.mylog.setLevel(50) |
| 25 | + |
24 | 26 | import numpy as np |
25 | 27 | from scipy.constants import c, e, epsilon_0, m_e |
26 | 28 |
|
@@ -75,7 +77,7 @@ def get_theoretical_field( field, t ): |
75 | 77 | # Check the validity of the fields |
76 | 78 | error_rel = 0 |
77 | 79 | for field in ['Ez']: |
78 | | - E_sim = data[field].to_ndarray()[:,0,0] |
| 80 | + E_sim = data[('mesh',field)].to_ndarray()[:,0,0] |
79 | 81 | E_th = get_theoretical_field(field, t0) |
80 | 82 | max_error = abs(E_sim-E_th).max()/abs(E_th).max() |
81 | 83 | print('%s: Max error: %.2e' %(field,max_error)) |
@@ -104,14 +106,14 @@ def get_theoretical_field( field, t ): |
104 | 106 | # current correction (psatd.do_current_correction=1) is applied or when |
105 | 107 | # Vay current deposition (algo.current_deposition=vay) is used |
106 | 108 | if current_correction or vay_deposition: |
107 | | - rho = data['rho' ].to_ndarray() |
108 | | - divE = data['divE'].to_ndarray() |
| 109 | + rho = data[('boxlib','rho')].to_ndarray() |
| 110 | + divE = data[('boxlib','divE')].to_ndarray() |
109 | 111 | error_rel = np.amax( np.abs( divE - rho/epsilon_0 ) ) / np.amax( np.abs( rho/epsilon_0 ) ) |
110 | 112 | tolerance = 1.e-9 |
111 | 113 | print("Check charge conservation:") |
112 | 114 | print("error_rel = {}".format(error_rel)) |
113 | 115 | print("tolerance = {}".format(tolerance)) |
114 | 116 | assert( error_rel < tolerance ) |
115 | 117 |
|
116 | | -test_name = fn[:-9] # Could also be os.path.split(os.getcwd())[1] |
| 118 | +test_name = os.path.split(os.getcwd())[1] |
117 | 119 | checksumAPI.evaluate_checksum(test_name, fn) |
0 commit comments