diff options
author | 2021-12-22 12:55:25 -0700 | |
---|---|---|
committer | 2021-12-22 19:55:25 +0000 | |
commit | f73b3cd49c430c59b6750d5e65dfd19dcf44c752 (patch) | |
tree | 2853a02755d260b690ba7373ab4ee0ff63a89de9 /Examples/Tests/ElectrostaticSphereEB/analysis_rz.py | |
parent | 011241af1c8feac1e1f8c726ac729a1216bd5d83 (diff) | |
download | WarpX-f73b3cd49c430c59b6750d5e65dfd19dcf44c752.tar.gz WarpX-f73b3cd49c430c59b6750d5e65dfd19dcf44c752.tar.zst WarpX-f73b3cd49c430c59b6750d5e65dfd19dcf44c752.zip |
Add embedded BC in RZ. (#2602)
* Start to add embedded BC in RZ.
* Add .
* Remove scaling
* Fix compilation error
* Update
* Can compile.
* Add call linop.setRZ(true).
* Remove lines 264 to 312 and 343 to 345.
* Add assert.
* Remove an assert.
* Add an automated test.
* Change to MLEBNodeFDLaplacian.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fix compilation error
* Update the test selection
* Correct compilation error
* Move test to another worker
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add new required argument
* Update Examples/Tests/ElectrostaticSphereEB/inputs_rz
* Update Examples/Tests/ElectrostaticSphereEB/analysis_rz.py
* Update analysis script
Co-authored-by: Remi Lehe <remi.lehe@normalesup.org>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'Examples/Tests/ElectrostaticSphereEB/analysis_rz.py')
-rwxr-xr-x | Examples/Tests/ElectrostaticSphereEB/analysis_rz.py | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/Examples/Tests/ElectrostaticSphereEB/analysis_rz.py b/Examples/Tests/ElectrostaticSphereEB/analysis_rz.py new file mode 100755 index 000000000..bb170f921 --- /dev/null +++ b/Examples/Tests/ElectrostaticSphereEB/analysis_rz.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python + +# Copyright 2019-2021 Yinjian Zhao +# +# This file is part of WarpX. +# +# License: BSD-3-Clause-LBNL + +# This script tests the embedded boundary in RZ. +# A cylindrical surface (r=0.1) has a fixed potential 1 V. +# The outer surface has 0 V fixed. +# Thus the analytical solution has the form: +# phi(r) = A+B*log(r), Er(r) = -B/r. + +# Possible errors: +# tolerance: 0.004 +# Possible running time: < 1 s + +import os +import sys + +import numpy as np +import yt + +sys.path.insert(1, '../../../../warpx/Regression/Checksum/') +import checksumAPI + +tolerance = 0.004 + +fn = sys.argv[1] +ds = yt.load( fn ) + +all_data_level_0 = ds.covering_grid(level=0,left_edge=ds.domain_left_edge, dims=ds.domain_dimensions) +phi = all_data_level_0['boxlib', 'phi'].v.squeeze() +Er = all_data_level_0['boxlib', 'Ex'].v.squeeze() + +Dx = ds.domain_width/ds.domain_dimensions +dr = Dx[0] +rmin = ds.domain_left_edge[0] +rmax = ds.domain_right_edge[0] +nr = phi.shape[0] +r = np.linspace(rmin+dr/2.,rmax-dr/2.,nr) +B = 1.0/np.log(0.1/0.5) +A = -B*np.log(0.5) + +err = 0.0 +errmax_phi = 0.0 +errmax_Er = 0.0 +for i in range(len(r)): + if r[i]>=0.1: + phi_theory = A+B*np.log(r[i]) + Er_theory = -B/float(r[i]) + err = abs( phi_theory - phi[i,:] ).max() / phi_theory + if err>errmax_phi: + errmax_phi = err + err = abs( Er_theory - Er[i,:] ).max() / Er_theory + # Exclude the last inaccurate interpolation. + if err>errmax_Er and i<len(r)-1: + errmax_Er = err + +print('max error of phi = ', errmax_phi) +print('max error of Er = ', errmax_Er) +print('tolerance = ', tolerance) +assert(errmax_phi<tolerance and errmax_Er<tolerance) + +test_name = os.path.split(os.getcwd())[1] +checksumAPI.evaluate_checksum(test_name, fn, do_particles=False) |