aboutsummaryrefslogtreecommitdiff
path: root/Examples/Tests/silver_mueller/analysis_silver_mueller.py
blob: bfab40aa9917f09384632c1ff0cf208959883b6a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3

# Copyright 2021
#
# This file is part of WarpX.
#
# License: BSD-3-Clause-LBNL
"""
This tests verifies the Silver-Mueller boundary condition.
A laser pulse is emitted and propagates towards the boundaries ; the
test check that the reflected field at the boundary is negligible.
"""

import os
import re
import sys

import numpy as np

import yt ; yt.funcs.mylog.setLevel(0)
sys.path.insert(1, '../../../../warpx/Regression/Checksum/')
import checksumAPI

filename = sys.argv[1]

ds = yt.load( filename )
all_data_level_0 = ds.covering_grid(level=0,left_edge=ds.domain_left_edge, dims=ds.domain_dimensions)
warpx_used_inputs = open('./warpx_used_inputs', 'r').read()
geom_RZ = re.search('geometry.dims = RZ', warpx_used_inputs)
if geom_RZ:
    Er = all_data_level_0['boxlib', 'Er'].v.squeeze()
    Et = all_data_level_0['boxlib', 'Et'].v.squeeze()
    Ez = all_data_level_0['boxlib', 'Ez'].v.squeeze()
else:
    Ex = all_data_level_0['boxlib', 'Ex'].v.squeeze()
    Ey = all_data_level_0['boxlib', 'Ey'].v.squeeze()
    Ez = all_data_level_0['boxlib', 'Ez'].v.squeeze()
# The peak of the initial laser pulse is on the order of 6 V/m
# Check that the amplitude after reflection is less than 0.01 V/m
max_reflection_amplitude = 0.01

if geom_RZ:
    assert np.all( abs(Er) < max_reflection_amplitude )
    assert np.all( abs(Et) < max_reflection_amplitude )
    assert np.all( abs(Ez) < max_reflection_amplitude )
else:
    assert np.all( abs(Ex) < max_reflection_amplitude )
    assert np.all( abs(Ey) < max_reflection_amplitude )
    assert np.all( abs(Ez) < max_reflection_amplitude )

test_name = os.path.split(os.getcwd())[1]
checksumAPI.evaluate_checksum(test_name, filename)