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 40 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
10 changes: 10 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,22 @@
nphi_equator = 16 # number of direction in equator
NF = 3 # number of flavors

'''
--------- 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]
'''

# 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
21 changes: 20 additions & 1 deletion Scripts/symbolic_hermitians/generate_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,4 +526,23 @@ def sgn(t,var):
code.append(dNdt.code())

code = [line for sublist in code for line in sublist]
write_code(code, os.path.join(args.emu_home, "Source/generated_files", "Evolve.cpp_dfdt_fill_zeros"))
write_code(code, os.path.join(args.emu_home, "Source/generated_files", "Evolve.cpp_dfdt_fill_zeros"))

#========================#
# Evolve.cpp_compute_trace #
#========================#

# List that will store the code for setting the derivative of the matrices N and Nbar to zero.
code = []

# Looping over neutrinos(tail: no tail) and antineutrinos(tail: bar)
for t in tails:

# Define n and nbar matrix
N = HermitianMatrix(args.N, "fab(i\,j\,k\,GIdx::N{}{}_{}"+t+")")
# Assign the trace of n and nbar to a variable
trace_N = N.trace()
code.append(["trace_n"+t+" = " + sympy.cxxcode(sympy.simplify(trace_N)) + ";"])

code = [line for sublist in code for line in sublist]
write_code(code, os.path.join(args.emu_home, "Source/generated_files", "Evolve.cpp_compute_trace"))
4 changes: 2 additions & 2 deletions Scripts/tests/coll_inst_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
t[i] = np.array(hf['t(s)'][:][0])

# Fit the exponential function ( y = a e ^ ( b x ) ) to the data
l1 = 10 # initial item for fit
l2 = 40 # last item for fit
l1 = 30 # initial item for fit
l2 = 70 # last item for fit
coefficients = np.polyfit(t[l1:l2], np.log(N_avg_mag[:,0,1][l1:l2]), 1)
coefficients_bar = np.polyfit(t[l1:l2], np.log(Nbar_avg_mag[:,0,1][l1:l2]), 1)
a = np.exp(coefficients[1])
Expand Down
6 changes: 3 additions & 3 deletions Scripts/tests/fermi_dirac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
directories = sorted(directories, key=lambda x: int(x.split("plt")[1].split(".")[0]))

# Energy bin centers extracted from NuLib table
energies_center_Mev = np.array([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
energies_center_Mev = np.array([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 = np.array([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])
energies_bottom_Mev = np.array([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 = np.array([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])
energies_top_Mev = np.array([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 * eV # Energy in ergs
Expand Down
35 changes: 34 additions & 1 deletion Source/Evolve.H
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,40 @@ namespace GIdx
void Initialize();
}

amrex::Real compute_dt(const amrex::Geometry& geom, const MultiFab& state, const FlavoredNeutrinoContainer& neutrinos, const TestParams* parms);
/**
* @brief Computes the maximum Inverse Mean Free Path (IMFP) for absorption and emission processes.
*
* This function calculates the maximum IMFP for absorption processes based on the specified method in the parameters.
* It supports two methods:
* 1. Using IMFP values from the input file.
* 2. Using a NuLib table to interpolate IMFP values.
*
* @param geom The geometry of the computational domain.
* @param state The MultiFab containing the state variables.
* @param parms Pointer to the TestParams structure containing the parameters for the computation.
* @return A MultiFab containing the maximum IMFP values.
*/
MultiFab compute_max_IMFP(const Geometry& geom, const MultiFab& state, const TestParams* parms);

/**
* @brief Computes the time step size for the simulation based on various CFL factors and conditions.
*
* This function calculates the time step size considering translation, flavor, and collision CFL factors.
* It ensures that the time step is limited by the smallest of these factors to maintain stability.
*
* @param geom The geometry of the simulation domain.
* @param state The state MultiFab containing the simulation data.
* @param neutrinos The container for flavored neutrinos.
* @param parms Pointer to the structure containing simulation parameters.
* @param maximum_IMFP_abs The MultiFab containing the maximum inverse mean free path for absorption.
*
* @return The computed time step size.
*
* @note At least one of cfl_factor, flavor_cfl_factor, or collision_cfl_factor must be greater than 0.0.
* @note The function handles periodic boundary conditions and black hole regions if specified in the parameters.
* @note The function performs a reduction operation to find the minimum time step across all cells and MPI ranks.
*/
amrex::Real compute_dt(const amrex::Geometry& geom, const MultiFab& state, const FlavoredNeutrinoContainer& neutrinos, const TestParams* parms, const MultiFab& maximum_IMFP_abs);

void deposit_to_mesh(const FlavoredNeutrinoContainer& neutrinos, amrex::MultiFab& state, const amrex::Geometry& geom);

Expand Down
Loading