Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erick/production 1.0 #106

Open
wants to merge 74 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 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
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
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}')
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()
11 changes: 8 additions & 3 deletions Scripts/data_reduction/convertToHDF5.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@ def convert_to_HDF5(sim_directory, DELETE_ALL_BUT_LAST_RESTART=False):
if d==fluid_directories[0]:
NF = eds.get_num_flavors()
allData = h5py.File(sim_directory+"/allData.h5","w")
allData["dx(cm)"] = eds.dx
allData["dy(cm)"] = eds.dy
allData["dz(cm)"] = eds.dz
allData["Nx"] = eds.Nx
allData["Ny"] = eds.Ny
allData["Nz"] = eds.Nz
allData.create_dataset("t(s)", data=np.zeros(0), maxshape=(None,), dtype=datatype)
allData.create_dataset("it", data=np.zeros(0), maxshape=(None,), dtype=int)

# create fluid data sets
maxshape = (None, eds.Nz)
chunkshape = (1, eds.Nz)
zeros = np.zeros((0,eds.Nz))
maxshape = (None,eds.Nx,eds.Ny,eds.Nz)
chunkshape = (1,eds.Nx,eds.Ny,eds.Nz)
zeros = np.zeros((0,eds.Nx,eds.Ny,eds.Nz))
varlist = []
for v in fluid_vars:
for f1 in range(NF):
Expand Down
16 changes: 16 additions & 0 deletions Scripts/initial_conditions/st9_empty_particles_multi_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,28 @@
nphi_equator = 16 # number of direction in equator
NF = 3 # number of flavors

'''
# Energy bins from NuLib table (No cutted)
--------- NuLib table energy bins ---------
# Energy bin centers extracted from NuLib table
energies_center_Mev = [1, 3, 5.23824, 8.00974, 11.4415, 15.6909, 20.9527, 27.4681, 35.5357, 45.5254, 57.8951, 73.2117, 92.1775, 115.662, 144.741, 180.748, 225.334, 280.542] # Energy in Mev
# Energy bin bottom extracted from NuLib table
energies_bottom_Mev = [0, 2, 4, 6.47649, 9.54299, 13.3401, 18.0418, 23.8636, 31.0725, 39.9989, 51.0519, 64.7382, 81.6853, 102.67, 128.654, 160.828, 200.668, 250]
# Energy bin top extracted from NuLib table
energies_top_Mev = [2, 4, 6.47649, 9.54299, 13.3401, 18.0418, 23.8636, 31.0725, 39.9989, 51.0519, 64.7382, 81.6853, 102.67, 128.654, 160.828, 200.668, 250, 311.085]
'''

# The following energy bins are an extraction of the NuLib table
# I have delete the first five energy bin to make the fermi-dirac test facter
# If I simulation want to run with all energy bins the user must change the energy bins manually

# Energy bins from NuLib table (Cutted)
# Energy bin centers extracted from NuLib table
energies_center_Mev = [15.6909, 20.9527, 27.4681, 35.5357, 45.5254, 57.8951, 73.2117, 92.1775, 115.662, 144.741, 180.748, 225.334, 280.542] # Energy in Mev
# Energy bin bottom extracted from NuLib table
energies_bottom_Mev = [13.3401, 18.0418, 23.8636, 31.0725, 39.9989, 51.0519, 64.7382, 81.6853, 102.67, 128.654, 160.828, 200.668, 250]
# Energy bin top extracted from NuLib table
energies_top_Mev = [18.0418, 23.8636, 31.0725, 39.9989, 51.0519, 64.7382, 81.6853, 102.67, 128.654, 160.828, 200.668, 250, 311.085]

# Energies in ergs
energies_center_erg = np.array(energies_center_Mev) * 1e6*amrex.eV # Energy in ergs
Expand Down
Loading