diff options
author | 2022-01-14 09:30:14 -0800 | |
---|---|---|
committer | 2022-01-14 17:30:14 +0000 | |
commit | 2efde6cd40e0a155f188c4f53d96a11aa9ac13ac (patch) | |
tree | 72ae24c05533b366ec29ad2c387a4e787167dd11 /Examples/Tests/FieldProbe/analysis_field_probe.py | |
parent | 400f536bed944f2e430f7c34dbb3fc00ac10332b (diff) | |
download | WarpX-2efde6cd40e0a155f188c4f53d96a11aa9ac13ac.tar.gz WarpX-2efde6cd40e0a155f188c4f53d96a11aa9ac13ac.tar.zst WarpX-2efde6cd40e0a155f188c4f53d96a11aa9ac13ac.zip |
Field probe line detector (#2513)
* FieldProbe using Particle
Update FieldProbe.cpp
Update FieldProbeParticleContainer.H
Updates FieldProbe and FieldProbeParticleContainer
* Make <diag>.integrate optional
The param parser query keeps te default value if no entry is found.
* Fixed number particle needed for AddNParticles
* Removing unnecessary type definition
* Added Doxygen-style comments to FieldProbe.cpp
Corrected Poynting calculation by implementing vacuum permeability
* Added Doxygen comments
* Implement virtual function ReducedDiags::AllocData() + comments
* InitData implemented
* Fixed Doxygen commenting.
* Now uses WarpX physics constant for vaccuum permeability
* forgotton comments to MultiReducedDiags
* Update Source/Diagnostics/ReducedDiags/FieldProbe.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update FieldProbe.H
* Update FieldProbe.cpp
* Update Source/Diagnostics/ReducedDiags/ReducedDiags.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/MultiReducedDiags.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/MultiReducedDiags.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update FieldProbeParticleContainer.H
* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update FieldProbeParticleContainer.cpp
* Update FieldProbe.cpp
* Update FieldProbe.H
* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.H
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update FieldProbeParticleContainer.cpp
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/ReducedDiags.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Changed enumerated class to struct w/ enumeration. Can remove "static_cast<int>"
* FieldProbeParticleContainer::iterator implemented
* Cleaned up output += operator, fixed output comments
* style fix
* Replaces Tabs with 4 spaces
* Defined modes and interp order to avoid GPU compilation errors
* 1 more tab fix
* EoL white spaces
* fixed a typoX
* Explicitly capturing "this" in parallel for to combat error saying "error #3223-D: Implicit capture of 'this' in extended lambda expression"
* removed unncessacesy double define
* moved output out of ParallelFor. temp variable for integrate
* Parse integrate, integrate all time steps, output setup for integrate and regular
* Fixed integrate bug.
* ammend header. integreate variable name change.
* Integrate values in input file
* updates to timing for integrate
* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* whitespace
* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update Source/Diagnostics/ReducedDiags/FieldProbeParticleContainer.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Functionality to create 2D line of particles. Input included. No output yet
* ammend compiler errors
* Apply suggestions from code review - Style
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update reduce_diag_names
* 2D array setup- not complete
* field_probe_integrate change
* review amends
* Apply suggestions from code review - Style
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Vectors + AddNParticles
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update FieldProbe.cpp
* Update FieldProbe.H
* bug fix and inputs
* reintroduce raw_fields functionality
* docs update and correction
* whitespaces
* Fix GPU Compile (raw_fields)
* changed f_probe to m_probe apropriately
* Typos
Co-authored-by: David Grote <dpgrote@lbl.gov>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Better name for ParticleVal
* used map for observables and units
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Simplified output. Fixed double integration error
* Update FieldProbe.H
Removed unneeded variable
* comments and fixed rawFields
* white spaces
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Update FieldProbe.H
* Guard on write
* Update Source/Diagnostics/ReducedDiags/FieldProbe.cpp
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Fix Syntax Error in Write
* Fix Init: Only 1 Particle (MPI)
Only one MPI rank adds a particle, which we done distribute
into the right rank.
* Fix MPI Deadlock: No Early Return
We just want to skip the write to `m_data`, not the rest
of the logic.
* Vector storage, Add N particle, debugging
* Fix Probe in Domain Logic
General global check, not only on a single rank.
* comments
* Container: Add `const_iterator`
* Fix MPI Comms
* Cleaning
* Remove PrintAll Leftover
* 1-D Output vector
* Reduced Diags: Support LoadBalance
* Cleaning of "Definitions ()"
* Updating inputs for testing Line
* data type specification
* IO
* Update inputs
* Update inputs
* error in header. Send to IO CPU
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* moved rank communication out of tile loop
* change m_data_vector. IO particle count
* Fixed input for rename. Gather particle number
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Gather
* Changed data output method to pushing values on vector
MPI Gather and Gatherv for data
Tell Evolve to run Load Balance
Tell InitData to run Load Balance
Define output method by printing valid particles
NOTE! Needs cleaning, commenting, removing some debugging tools
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Suggestions from review
* defensive programming on if / if else
added comments throughout
removed temporary debugging lines
* Documentation for line detector option
* Whitespaces
* MPI_Gather -> amrex::ParallelDescriptor::Gather
* ParallelDiscriptor, vectors at the end, no more 1990's malloc for capacity allocation
* whitespaces
* output optimized for CSV
* Python notebook for reference
* Input file for current test on CORI
* 2D plane functionality
* Regression test
* Delete DoubleSlit_2021_11_17.ipynb
* Whitespace fix
* pandas
* Error set to 2.5%, fixed source
* style
* zenodo orcid
* Apply suggestions from code review
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
* Review changes and swapped MPI direct call for Amrex::ParallelDescriptor
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update WarpX-tests.ini
Fix Regression Test
* Update WarpX-tests.ini
Open PMD in cmakeSetupOpts
* Update dependencies.rst
* Update analysis_field_probe.py
* Update WarpX-tests.ini
* Analysis Script: Executable
```
chmod a+x scriptname.py
```
and use explicitly `python3`
* openPMD: optional for this test
* Inputs: add `geometry.dims = 2`
* Remove: diag1.write_species = 0
- segfaults for plotfiles (bug?)
- not needed, since we have no particles anyway
* Fix: typo in analysis
* test requirements: pandas
* Fix: Types
* as string: `<red_diag>.probe_geometry`
change this to a string, which is more user-friendly
* Python Script: Simplify + Style
* C++: Clean Up
* Azure: Run `apt update`
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Co-authored-by: David Grote <dpgrote@lbl.gov>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'Examples/Tests/FieldProbe/analysis_field_probe.py')
-rwxr-xr-x | Examples/Tests/FieldProbe/analysis_field_probe.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Examples/Tests/FieldProbe/analysis_field_probe.py b/Examples/Tests/FieldProbe/analysis_field_probe.py new file mode 100755 index 000000000..7d7eaa0eb --- /dev/null +++ b/Examples/Tests/FieldProbe/analysis_field_probe.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +# +# Copyright 2021-2022 Tiberius Rheaume +# +# This file is part of WarpX. +# +# License: BSD-3-Clause-LBNL + +""" +This script tests the accuracy of the FieldProbe diagnostic by observing a plane +wave undergoing single slit diffraction. The input file inputs_2d is used. This +file defines the simulation box, laser pulse, embeded boundary with single slit, +and line of detector points. The plane wave initializes near the negative Z end +of the simulation box. The wave interacts with the embeded boundary at Z=0. The +wave undergoes diffraction at the slit. The electromagnetic flux is calculated +at the line detector which is placed perpendicular to Z beyond the slit. This +test will check if the detected EM flux matches expected values, +which can be solved analytically. +""" +import numpy as np +import pandas as pd + +filename = "diags/reducedfiles/FP_line.txt" + +# Open data file +df = pd.read_csv(filename, sep=' ') +df = df.sort_values(by=['[2]part_x_lev0-(m)']) + +# Select position and Intensity of timestep 500 +x = df.query('`[0]step()` == 500')['[2]part_x_lev0-(m)'] +S = df.query('`[0]step()` == 500')['[11]part_S_lev0-(W*s/m^2)'] +xvals = x.to_numpy() +svals = S.to_numpy() + +# Default intensity is highest measured value for plane +# wave interacting with single slit +I_0 = np.max(S) +def I_envelope (x, lam = 0.2e-6, a = 0.3e-6, D = 1.7e-6): + arg = np.pi * a / lam * np.sin(np.arctan(x / D)) + return np.sinc( arg / np.pi )**2 + +# Count non-outlyer values away from simulation boundaries +counter = np.arange(60, 140, 2) + +# Count average error from expected values +error = 0 +for a in counter: + b = I_0 * I_envelope(xvals[a]) + c = svals[a] + error += abs((c-b)/b) * 100.0 +averror = error / (len(counter) - 1) + +# average error range set at 2.5% +if averror > 2.5: + print('Average error greater than 2.5%') + +assert averror < 2.5 |