Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
7a53b35
Make IMFP calculation energy dependent
shankar-1729 Nov 4, 2024
de0bac5
Ensure that rho, temp and Ye are uniformally spaced.
shankar-1729 Nov 4, 2024
7daa907
Implement function to calculate maximum of IMFP over the grid (UNTESTED)
shankar-1729 Oct 26, 2024
2c67c2e
Move multifab for IMFB inside compute_max_IMFP function, correct temp…
shankar-1729 Oct 30, 2024
795615c
do not input ba, dm and ngrow inside compute_max_IMFP function
shankar-1729 Oct 30, 2024
a9d22c4
calculate max_IMFP_abs inside function compute_dt
shankar-1729 Oct 30, 2024
66eeb3c
Remove dt calculation from compute_dt function
shankar-1729 Oct 31, 2024
3480a61
Adding basics comments and documentation to new functions
erickurquilla1999 Nov 4, 2024
8458eae
Change the position of the calculation of the maximum IMFP
erickurquilla1999 Nov 4, 2024
792c8fd
Compute maximum of IMFP when IMFP method is 1 too
erickurquilla1999 Nov 4, 2024
4b43fff
Compute the maximum IMFP and pass it as a parameter to the compute_dt…
erickurquilla1999 Nov 4, 2024
db60725
Cleaning up the compute_dt function and adding documentation.
erickurquilla1999 Nov 4, 2024
d02f865
Include a generated file to compute the trace of the neutrino number …
erickurquilla1999 Nov 4, 2024
0959355
Solving issue in generated file to compute trace of mesh neutrino and…
erickurquilla1999 Nov 4, 2024
b4c008b
Compute maximum trace of the neutrino and antineutrino from mesh quan…
erickurquilla1999 Nov 4, 2024
0399808
Create a function that computes the minimum value in a MultiFab in pa…
erickurquilla1999 Nov 5, 2024
be783b9
Set some if statements to handle simulations with empty periodic boun…
erickurquilla1999 Nov 5, 2024
d8e9f1e
Generate a new file to compute the trace on mesh quantities
erickurquilla1999 Nov 5, 2024
c5c70ed
Solve syntaxis mistakes and compute the minumin time step rather than…
erickurquilla1999 Nov 5, 2024
9703bac
Make function compute_max_IMFP return a multifab with the maximum inv…
erickurquilla1999 Nov 5, 2024
aada239
Compute the minimum combination of TrN/Opacity*c. This quantity provi…
erickurquilla1999 Nov 5, 2024
8a737ea
Delete commented lines and handle periodic empty boundary conditions …
erickurquilla1999 Nov 5, 2024
3420c23
Cleaning up and addiing comments to the compute_dt function
erickurquilla1999 Nov 5, 2024
4594186
Add documentation for header file of Evolve.cpp file
erickurquilla1999 Nov 5, 2024
acbf75d
Delete unnecessary generation of two files that compute the trace.
erickurquilla1999 Nov 5, 2024
2296774
Setting the min(TrN, TrNbar) to one in case it is zero
erickurquilla1999 Nov 5, 2024
97e981e
Cleaning space
erickurquilla1999 Nov 5, 2024
c1be327
Cleaning up compute_max_IMFP function
erickurquilla1999 Nov 5, 2024
af7a2c8
Creating documentation for compute_max_IMFP function
erickurquilla1999 Nov 5, 2024
08fc11f
Set the new time step to agree with the new function that computes th…
erickurquilla1999 Nov 5, 2024
dac02e9
Solving issue when looping over the MultiFabs. Now it does not loop o…
erickurquilla1999 Nov 6, 2024
f76d6fb
Delete unnecessary lines
erickurquilla1999 Nov 6, 2024
1021c4e
Update empty periodic boundary condition test
erickurquilla1999 Nov 6, 2024
aa6f913
Setting the right cfl factors for particles to equilibrium test
erickurquilla1999 Nov 6, 2024
ec29a9b
Set up the Fermi-Dirac test for multi-energy particles with the follo…
erickurquilla1999 Nov 6, 2024
8f7094b
Delete unnecessary functions
erickurquilla1999 Nov 6, 2024
a114cc8
Solving possible issue with zero inverse mean free path
erickurquilla1999 Nov 6, 2024
7358916
Improve documentation
erickurquilla1999 Nov 6, 2024
2a3525d
Solve syntax issue
erickurquilla1999 Nov 6, 2024
94a9bf2
Solving issue with fermi dirac test
erickurquilla1999 Nov 7, 2024
3f60f26
Fix time step function: now calculates the time step based on a basic…
erickurquilla1999 Nov 25, 2024
f1c9cd7
Adding comments on the definitions of V_stupid and V_adaptive
erickurquilla1999 Nov 25, 2024
216fc2a
Delete unnecessary line that computes the trace of matrices.
erickurquilla1999 Nov 25, 2024
f09220b
Add input parameter for the minimum allowed time step in the simulation
erickurquilla1999 Nov 25, 2024
981c3e2
Including the minimum time step barrier in the function that computes…
erickurquilla1999 Nov 25, 2024
94af9fb
Including a new neutrino container to store the minimum dt for every …
erickurquilla1999 Nov 25, 2024
9255937
Delete documentation in Evolve.H header file and input the time step …
erickurquilla1999 Nov 25, 2024
bd4be86
Add a flag to choose between two different methods for computing the …
erickurquilla1999 Nov 25, 2024
2835ede
Add a new method to compute the time step based on the time derivativ…
erickurquilla1999 Nov 25, 2024
e49ff1b
Delete unnecessary variables and comments.
erickurquilla1999 Nov 25, 2024
d437789
Add time_step_method flag to input parameters.
erickurquilla1999 Nov 25, 2024
4873d89
Update input parameters.
erickurquilla1999 Nov 25, 2024
f5e9e71
Improve script that compute dE and antineutrino chemical potential fo…
erickurquilla1999 Nov 25, 2024
f37885e
Setting asserts at the end of the collisional flavor instability test…
erickurquilla1999 Nov 25, 2024
5ed145b
Fix issue with Method 1 for computing the time step
erickurquilla1999 Nov 25, 2024
c7dbd0d
Set collisional flavor instability test to use Method 1 for computing…
erickurquilla1999 Nov 25, 2024
e8f4b84
Fix issue in method 0 to compute time step
erickurquilla1999 Nov 25, 2024
d6c37a4
Adding comments in st9 initial condition to avoid future confusion
erickurquilla1999 Nov 25, 2024
653bc78
Adding comments to avoid future confusion in fermi-dirac test
erickurquilla1999 Nov 25, 2024
40a853b
Remove 'FIXME' comments.
erickurquilla1999 Nov 25, 2024
34f27cf
Return mf_IMFP at the end of the function instead of in every if stat…
erickurquilla1999 Nov 25, 2024
a5f4b30
Delete print line in main
erickurquilla1999 Nov 25, 2024
c2aa1b4
Create a script to plot the polarization vector components for single…
erickurquilla1999 Nov 25, 2024
501fe69
Add an if statement to compute the IMFP MultiFab only when the time s…
erickurquilla1999 Nov 25, 2024
1652a0e
Set the maximum grid size for every direction in the domain.
erickurquilla1999 Nov 25, 2024
61c025d
Update input file to define max grid size in every direction in the d…
erickurquilla1999 Nov 25, 2024
86e8500
Making convertToHDF5.py script works in 3D simulations
erickurquilla1999 Nov 27, 2024
0de65c0
Adding a line to stop execution when a NaN appears in N and N bar
erickurquilla1999 Nov 29, 2024
e02dc74
Improve section the leave the code is N or Nbar is NaN
erickurquilla1999 Nov 29, 2024
9ea0ae6
Plotting best figures in collisional instability test
erickurquilla1999 Dec 2, 2024
8b44a36
Adding units to labels and legends
erickurquilla1999 Dec 2, 2024
104bb0f
Updating plots and legens in CFI test
erickurquilla1999 Dec 2, 2024
8c92437
Delete lines that import unused packages in the collisional instabili…
erickurquilla1999 Dec 4, 2024
4e61f3d
Setting optimal max_grid_size in tests input file
erickurquilla1999 Dec 4, 2024
e01666d
Add a script to save particle information from binary to HDF5, organi…
erickurquilla1999 Jan 4, 2025
b403f71
Optimizing script that write particles data per cell. Now it only doe…
erickurquilla1999 Jan 4, 2025
e37eeb7
Create a new script for parallel optimization of the write_partices_p…
erickurquilla1999 Jan 4, 2025
773a933
Adding an script that write particle information parallelized over grids
erickurquilla1999 Jan 4, 2025
2d5a3c6
Solving issue creating particles file
erickurquilla1999 Jan 4, 2025
3c62f34
Delete thread parallelization
erickurquilla1999 Jan 4, 2025
bfbba28
Update write particles per cell script to recive the grid index as in…
erickurquilla1999 Jan 4, 2025
2ab5ab3
Delete file
erickurquilla1999 Jan 4, 2025
cdd589e
Fix issue with number of amrex grid subdivision
erickurquilla1999 Jan 4, 2025
eaa2414
Add line to write pressure moment in the H5 file (it is commented but…
erickurquilla1999 Jan 30, 2025
44b9535
Solve mistake in help message
Feb 18, 2025
1d06781
Add script compute n and f from particles data and compare with the d…
Feb 18, 2025
2febf93
Add the particle interpolator functions in a single python script
erickurquilla1999 Feb 18, 2025
24be1e8
Moving the particle interpolator class from this script to a
erickurquilla1999 Feb 18, 2025
2cf0a6e
Add scrit to plot angular distributions in cells
erickurquilla1999 Feb 18, 2025
3d28566
Change name of python script to generate constant backgorund data for…
erickurquilla1999 Feb 27, 2025
52fd30c
Delete script that do not need to be in the EMU repository
erickurquilla1999 Feb 27, 2025
74ab3c7
Create script that convert the cell hdf5 files into a particle_input.…
erickurquilla1999 Mar 3, 2025
78c2085
Dividing by volume quantites that should be written as densities
erickurquilla1999 Mar 13, 2025
05356df
Solve issue with amrex GpuTuple with no definition of variable types
erickurquilla1999 May 8, 2025
68a5b1b
Trying saving particle data with WritePlotFile instead of Checkpoint …
erickurquilla1999 May 9, 2025
87aedd9
Print just time step number and physical time
erickurquilla1999 May 27, 2025
d60c5ec
Making the input parameters of the script that split particle data pe…
erickurquilla1999 Jun 2, 2025
f334bb5
Make the file that convert average data to hdf5 file read plt file nu…
erickurquilla1999 Jun 2, 2025
a680ead
Sorting directories when splitting particles data per cell
erickurquilla1999 Jun 3, 2025
d9d9e04
Going back to checkpoints to save particle data
erickurquilla1999 Jun 10, 2025
d2983d0
Generate initial conditions script for local CFI simulations
erickurquilla1999 Jun 13, 2025
4886d59
Add the possibility of defining an arbitrary equilibrium distribution…
erickurquilla1999 Jun 19, 2025
8c0b8b9
Add paramter to control arbitrary equilibrium in CFI inputs_collision…
erickurquilla1999 Jul 15, 2025
f0bf719
Convert data to hdf5 for all plt file. Previously is only analize the
erickurquilla1999 Aug 1, 2025
0ba3dde
Fix issue when trying to read data from plt files, now it order the d…
erickurquilla1999 Aug 22, 2025
c49fe24
Adding attenuation paramters for every type of hamiltonian
erickurquilla1999 Aug 22, 2025
641fa06
Update Jenkinsfile
erickurquilla1999 Aug 22, 2025
0807ece
Solve issue when saving pdf in collision to equilibrium test
erickurquilla1999 Aug 22, 2025
fb2c16d
Modifications necessary to include a 3-velocity in the stored grid va…
cellio00 Sep 25, 2025
0c97875
added units to velocity parameters for consistency.
cellio00 Sep 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pipeline {

stage('Fast Flavor'){ steps{
dir('Exec'){
sh 'python ../Scripts/initial_conditions/st2_2beam_fast_flavor.py'
sh 'python ../Scripts/initial_conditions/st2_2beam_fast_flavor.py'
sh 'mpirun -np 4 ./main3d.gnu.TPROF.MPI.CUDA.ex ../sample_inputs/inputs_fast_flavor'
sh 'python ../Scripts/tests/fast_flavor_test.py'
sh 'rm -rf plt*'
Expand All @@ -54,7 +54,7 @@ pipeline {

stage('Fast Flavor k'){ steps{
dir('Exec'){
sh 'python ../Scripts/initial_conditions/st3_2beam_fast_flavor_nonzerok.py'
sh 'python ../Scripts/initial_conditions/st3_2beam_fast_flavor_nonzerok.py'
sh 'mpirun -np 4 ./main3d.gnu.TPROF.MPI.CUDA.ex ../sample_inputs/inputs_fast_flavor_nonzerok'
sh 'python ../Scripts/tests/fast_flavor_k_test.py'
sh 'rm -rf plt*'
Expand All @@ -80,26 +80,13 @@ pipeline {
}
}

stage('Fiducial 3F CPU HDF5'){ steps{
dir('Exec'){
sh 'cp ../makefiles/GNUmakefile_jenkins_HDF5 GNUmakefile'
sh 'make realclean; make generate; make -j'
sh 'python ../Scripts/initial_conditions/st4_linear_moment_ffi_3F.py'
sh 'mpirun -np 4 ./main3d.gnu.TPROF.MPI.ex ../sample_inputs/inputs_1d_fiducial'
/*sh 'python3 ../Scripts/babysitting/avgfee_HDF5.py'*/
sh 'rm -rf plt*'
}
}
}

stage('Collisions flavor instability'){ steps{
dir('Exec'){
sh 'cp ../makefiles/GNUmakefile_jenkins_HDF5_CUDA GNUmakefile'
sh 'make realclean; make generate NUM_FLAVORS=2; make -j NUM_FLAVORS=2'
sh 'python ../Scripts/initial_conditions/st8_coll_inst_test.py'
sh 'mpirun -np 4 ./main3d.gnu.TPROF.MPI.CUDA.ex ../sample_inputs/inputs_collisional_instability_test'
sh 'python ../Scripts/data_reduction/reduce_data.py'
sh 'python ../Scripts/tests/coll_inst_test.py'
archiveArtifacts artifacts: '*.pdf'
sh 'rm -rf plt* *pdf'
}
}
Expand All @@ -109,26 +96,40 @@ pipeline {
sh 'mpirun -np 4 ./main3d.gnu.TPROF.MPI.CUDA.ex ../sample_inputs/inputs_bc_periodic_init'
sh 'python ../Scripts/collisions/writeparticleinfohdf5.py'
sh 'python ../Scripts/tests/bc_empty_init_test.py'
archiveArtifacts artifacts: '*.pdf'
sh 'rm -rf plt* *pdf'
}
}
}

stage('Fiducial 3F CPU HDF5'){ steps{
dir('Exec'){
sh 'cp ../makefiles/GNUmakefile_jenkins_HDF5 GNUmakefile'
sh 'make realclean; make generate; make -j'
sh 'python ../Scripts/initial_conditions/st4_linear_moment_ffi_3F.py'
sh 'mpirun -np 4 ./main3d.gnu.TPROF.MPI.ex ../sample_inputs/inputs_1d_fiducial'
/*sh 'python3 ../Scripts/babysitting/avgfee_HDF5.py'*/
sh 'rm -rf plt*'
}
}
}

stage('Collisions to equilibrium'){ steps{
dir('Exec'){
sh 'cp ../makefiles/GNUmakefile_jenkins_HDF5_CUDA GNUmakefile'
sh 'make realclean; make generate NUM_FLAVORS=3; make -j NUM_FLAVORS=3'
sh 'python ../Scripts/initial_conditions/st7_empty_particles.py'
sh 'mpirun -np 4 ./main3d.gnu.TPROF.MPI.CUDA.ex ../sample_inputs/inputs_coll_equi_test'
sh 'python ../Scripts/tests/coll_equi_test.py'
sh 'rm -rf plt* *pdf'
sh 'rm -rf plt*'
}
}
}

stage('Fermi-Dirac test'){ steps{
dir('Exec'){
sh 'python ../Scripts/initial_conditions/st9_empty_particles_multi_energy.py'
sh 'python ../Scripts/collisions/nsm_constant_background_rho_Ye_T__writer.py'
sh 'python ../Scripts/collisions/nsm_constant_background_rho_Ye_T_writer.py'
sh 'mpirun -np 4 ./main3d.gnu.TPROF.MPI.CUDA.ex ../sample_inputs/inputs_fermi_dirac_test'
sh 'python ../Scripts/collisions/writeparticleinfohdf5.py'
sh 'python ../Scripts/tests/fermi_dirac_test.py'
Expand Down
15 changes: 11 additions & 4 deletions Scripts/collisions/compute_dE_coll_inst_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@
hc = h * c # erg cm

# Simulation parameters
V = 1 # Volume of a cell ( ccm )
V = (1.0e3)**3 # Volume of a cell ( ccm )
Ndir = 92 # Number of momentum beams isotropically distributed per cell
E = 20.0 # Neutrinos and antineutrinos energy bin center ( Mev )
T = 7.0 # Background matter temperature ( Mev )

N_eq_electron_neutrino = 3.260869565e+31 # Number of electron neutrinos at equilibrium
N_eq_electron_neutrino_density = 3.0e33 # Density of electron neutrinos at equilibrium (ccm)
N_eq_electron_neutrino = N_eq_electron_neutrino_density * V / Ndir # Number of electron neutrinos at equilibrium per beam
print(f'Number of electron neutrinos at equilibrium per beam = {N_eq_electron_neutrino}')
u_electron_neutrino = 20.0 # Electron neutrino chemical potential ( Mev )

# Fermi-dirac distribution factor for electron neutrinos
f_eq_electron_neutrinos = 1 / ( 1 + np.exp( ( E - u_electron_neutrino ) / T ) ) # adimentional
print(f'Fermi-Dirac distribution factor for electron neutrinos = {f_eq_electron_neutrinos}')

# We know :
# dE^3 = 3 * Neq * ( hc )^ 3 / ( dV * dOmega * feq )
Expand All @@ -47,9 +50,13 @@
dE=np.real(complex_deltaE)

# Electron neutrino flavor
N_eq_electron_antineutrino = 2.717391304e+31 # Number of electron antineutrinos at equilibrium
N_eq_electron_antineutrino_density = 2.5e33 # Density of electron antineutrinos at equilibrium (ccm)
N_eq_electron_antineutrino = N_eq_electron_antineutrino_density * V / Ndir # Number of electron antineutrinos at equilibrium per beam
print(f'Number of electron antineutrinos at equilibrium per beam = {N_eq_electron_antineutrino}')
Vphase = V * ( 4 * np.pi / Ndir ) * delta_E_cubic / 3
print(f'Phase space volume in ccm MeV^3 = {Vphase}')

# Computing electron antineutrino chemical potential
f_eq_electron_antineutrino = 3 * N_eq_electron_antineutrino * ( hc )**3 / ( V * ( 4 * np.pi / Ndir ) * delta_E_cubic )
u_electron_antineutrino = E - T * np.log( 1 / f_eq_electron_antineutrino - 1 )
print(f'Electron neutrino chemical potential in MeV = {u_electron_antineutrino}')
print(f'Electron antineutrino chemical potential in MeV = {u_electron_antineutrino}')
79 changes: 79 additions & 0 deletions Scripts/collisions/convert_cellh5_inidat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'''
Created by Erick Urquilla, Department of Physics and Astronomy, University of Tennessee, Knoxville.
This script convert the cell hdf5 files into a particle_input.dat file that can be used as an initial condition
for the Emu code.
The cell hdf5 files are generated by the script write_particles_per_cell.py
The particle data is stored in hdf5 files with the following labels: cell_i_j_k.h5
where i, j, k are the cell indexes in the x, y, z directions respectively.
The ddf5 files has to be in the directory this script is run.
'''

import glob
import h5py
import numpy as np
import sys
import os
importpath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(importpath)
sys.path.append(importpath+"/../initial_conditions")
from initial_condition_tools import uniform_sphere, write_particles
import amrex_plot_tools as amrex

def read_hdf5_file(file_name):
"""
Reads an HDF5 file and returns its datasets as a dictionary.

Parameters:
file_name (str): Path to the HDF5 file.

Returns:
dict: A dictionary where keys are dataset names and values are NumPy arrays.
"""
with h5py.File(file_name, 'r') as file:
return {dataset: np.array(file[dataset]) for dataset in file.keys()}

# Find all files matching the pattern
file_pattern = 'cell_*_*_*.h5'
files = glob.glob(file_pattern)

data = read_hdf5_file(files[0])

labels_nf2=['pos_x','pos_y','pos_z', 'time', 'x', 'y', 'z', 'pupx', 'pupy', 'pupz', 'pupt', 'N00_Re', 'N01_Re', 'N01_Im', 'N11_Re', 'N00_Rebar', 'N01_Rebar', 'N01_Imbar', 'N11_Rebar', 'TrHN', 'Vphase']
labels_nf3=['pos_x','pos_y','pos_z','time','x', 'y', 'z', 'pupx', 'pupy', 'pupz', 'pupt', 'N00_Re', 'N01_Re', 'N01_Im', 'N02_Re', 'N02_Im', 'N11_Re', 'N12_Re', 'N12_Im' ,'N22_Re', 'N00_Rebar', 'N01_Rebar', 'N01_Imbar', 'N02_Rebar', 'N02_Imbar', 'N11_Rebar', 'N12_Rebar' ,'N12_Imbar', 'N22_Rebar', 'TrHN', 'Vphase']

NF = 0
if len(data.keys()) == len(labels_nf2):
labels = labels_nf2
NF = 2
elif len(data.keys()) == len(labels_nf3):
labels = labels_nf3
NF = 3
else:
print(f'len(data.keys()) = {len(data.keys())} does not match any of the known labels')
exit(1)

# Get variable keys
rkey, ikey = amrex.get_particle_keys(NF, ignore_pos=True)

# Generate the number of variables that describe each particle
n_variables = len(rkey)

# Generate the number of particles
n_particles = len(data[labels[0]])

# Initialize a NumPy array to store all particles
particles = np.zeros((n_particles, n_variables))

# Volume of the simulation box
volume = 1e5**3 # ccm

for label in rkey:

print(f'Writing {label} to particles')
particles[:, rkey[label]] = data[label]

if (label.startswith('N') | label.startswith('Vphase')):
particles[:, rkey[label]] /= volume

# Write particles initial condition file
write_particles(np.array(particles), NF, "particle_input.dat")
100 changes: 100 additions & 0 deletions Scripts/collisions/single_particle_plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
'''
Created by Erick Urquilla. University of Tennessee Knoxville, USA.
This script is used to plot the single particle polarization vector in the x, y, and z directions.
This script works exclusively for the two flavor case.
The script reads the plt files generated with the writeparticleinfohdf5.py script.
'''

import numpy as np
import glob
import h5py
import matplotlib.pyplot as plt

file_names = np.array(glob.glob('plt*.h5'))
file_names = [file_name for file_name in file_names if '_reduced_data' not in file_name]
file_names.sort(key=lambda x: int(x.split('plt')[1].split('.h5')[0]))

particle_momentum = [0,0,0,0]
with h5py.File(file_names[0], 'r') as hdf:
data = {}
for key in hdf.keys():
data[key] = np.array(hdf.get(key))
particle_momentum[0] = data['pupx'][0]
particle_momentum[1] = data['pupy'][0]
particle_momentum[2] = data['pupz'][0]
particle_momentum[3] = data['pupt'][0]

time = np.zeros(len(file_names))
N00_Re = np.zeros(len(file_names))
N00_Rebar = np.zeros(len(file_names))
N01_Im = np.zeros(len(file_names))
N01_Imbar = np.zeros(len(file_names))
N01_Re = np.zeros(len(file_names))
N01_Rebar = np.zeros(len(file_names))
N11_Re = np.zeros(len(file_names))
N11_Rebar = np.zeros(len(file_names))

for i, file in enumerate(file_names):
with h5py.File(file, 'r') as hdf:

# ['N00_Re', 'N00_Rebar', 'N01_Im', 'N01_Imbar', 'N01_Re', 'N01_Rebar', 'N11_Re', 'N11_Rebar', 'TrHN', 'Vphase', 'pos_x', 'pos_y', 'pos_z', 'pupt', 'pupx', 'pupy', 'pupz', 'time', 'x', 'y', 'z']

data = {}
for key in hdf.keys():
data[key] = np.array(hdf.get(key))

for j in range(len(data['pupx'])):
if (data['pupx'][j] == particle_momentum[0] and
data['pupy'][j] == particle_momentum[1] and
data['pupz'][j] == particle_momentum[2] and
data['pupt'][j] == particle_momentum[3]):
time[i] = data['time'][j]
N00_Re[i] = data['N00_Re'][j]
N00_Rebar[i] = data['N00_Rebar'][j]
N01_Im[i] = data['N01_Im'][j]
N01_Imbar[i] = data['N01_Imbar'][j]
N01_Re[i] = data['N01_Re'][j]
N01_Rebar[i] = data['N01_Rebar'][j]
N11_Re[i] = data['N11_Re'][j]
N11_Rebar[i] = data['N11_Rebar'][j]
break

P_x = 0.5 * N01_Re
P_y = 0.5 * N01_Im
P_z = 0.5 * (N00_Re - N11_Re)

# Plot P_x vs P_y
plt.plot(P_x, P_y, color='gray', alpha=0.5)
sc = plt.scatter(P_x, P_y, c=time, cmap='viridis')
plt.colorbar(sc, label=r'$t \, (s)$')
plt.xlabel(r'$P_x$')
plt.ylabel(r'$P_y$')
plt.savefig('particle_momentum_plot_Px_Py.pdf')
plt.close()

# Plot log(P_x) vs log(P_y)
plt.plot(np.log10(np.abs(P_x)), np.log10(np.abs(P_y)), color='gray', alpha=0.5)
sc = plt.scatter(np.log10(np.abs(P_x)), np.log10(np.abs(P_y)), c=time, cmap='viridis')
plt.colorbar(sc, label=r'$t \, (s)$')
plt.xlabel(r'$\log_{10}(|P_x|)$')
plt.ylabel(r'$\log_{10}(|P_y|)$')
plt.savefig('particle_momentum_plot_log_Px_Py.pdf')
plt.close()

# Plot P_x vs P_z
plt.plot(P_x, P_z, color='gray', alpha=0.5)
sc = plt.scatter(P_x, P_z, c=time, cmap='viridis')
plt.colorbar(sc, label=r'$t \, (s)$')
plt.xlabel(r'$P_x$')
plt.ylabel(r'$P_z$')
plt.savefig('particle_momentum_plot_Px_Pz.pdf')
plt.close()

# Plot P_y vs P_z
plt.plot(P_y, P_z, color='gray', alpha=0.5)
sc = plt.scatter(P_y, P_z, c=time, cmap='viridis')
plt.colorbar(sc, label=r'$t \, (s)$')
plt.xlabel(r'$P_y$')
plt.ylabel(r'$P_z$')
plt.savefig('particle_momentum_plot_Py_Pz.pdf')
plt.close()
Loading