diff options
author | 2020-01-09 17:54:17 +0100 | |
---|---|---|
committer | 2020-01-09 17:54:17 +0100 | |
commit | 1ebfed117e098b211c83d196c1939611e1524b40 (patch) | |
tree | 226f35cd766fc9215feb193d5d79ea8a527d0d9d /Examples/Modules | |
parent | a8463214e71b18d08763528cd546e92fe7de848d (diff) | |
download | WarpX-1ebfed117e098b211c83d196c1939611e1524b40.tar.gz WarpX-1ebfed117e098b211c83d196c1939611e1524b40.tar.zst WarpX-1ebfed117e098b211c83d196c1939611e1524b40.zip |
fixed small bug
Diffstat (limited to 'Examples/Modules')
-rwxr-xr-x | Examples/Modules/laser_injection_from_file/analysis.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/Examples/Modules/laser_injection_from_file/analysis.py b/Examples/Modules/laser_injection_from_file/analysis.py index b8d0899f0..d1ef8a001 100755 --- a/Examples/Modules/laser_injection_from_file/analysis.py +++ b/Examples/Modules/laser_injection_from_file/analysis.py @@ -80,6 +80,11 @@ def gauss_env(T,XX,ZZ): return E_max * np.real(np.exp(exp_arg)) def write_file(fname, x, y, t, E): + """ For a given filename fname, space coordinates x and y, time coordinate t + and field E, write a WarpX-compatible input binary file containing the + profile of the laser pulse + """ + with open(fname, 'wb') as file: flag_unif = 0 file.write(flag_unif.to_bytes(1, byteorder='little')) @@ -93,6 +98,12 @@ def write_file(fname, x, y, t, E): def write_file_unf(fname, x, y, t, E): + """ For a given filename fname, space coordinates x and y, time coordinate t + and field E, write a WarpX-compatible input binary file containing the + profile of the laser pulse. This function should be used in the case + of a uniform spatio-temporal mesh + """ + with open(fname, 'wb') as file: flag_unif = 1 file.write(flag_unif.to_bytes(1, byteorder='little')) @@ -103,11 +114,13 @@ def write_file_unf(fname, x, y, t, E): file.write(t[-1].tobytes()) file.write(x[0].tobytes()) file.write(x[-1].tobytes()) - file.write(y[0].tobytes()) - file.write(y[-1].tobytes()) + if len(y) == 1 : + file.write(y[0].tobytes()) + else : + file.write(y[0].tobytes()) + file.write(y[-1].tobytes()) file.write(E.tobytes()) - def create_gaussian_2d(): T, X, Y = np.meshgrid(tcoords, xcoords, np.array([0.0]), indexing='ij') E_t = gauss(T,X,Y,'2d') |