Skip to content

Commit

Permalink
v1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Taygun Bulmus committed Oct 23, 2022
1 parent 4fc2a02 commit 4d39b62
Show file tree
Hide file tree
Showing 19 changed files with 798 additions and 196 deletions.
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Python Caches
*.pyc
*__pycache__*/

# Folders to ignore
backgroundProfiles/
tmp/
results/
parameters/old
snSimulations/
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
],
"cSpell.ignoreWords": [
"Abbar",
"Athar",
"DISTDIAG",
"Emod",
"Keil",
"LSODA",
"Termb",
"Valeig",
"Xsdat",
"cdist",
"ebar",
"figsize",
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# v1.1
- Updated gitignore.
- Converted `plotgraphsScript.sh` to python script (`plotGraphsAfterSimulation.py`). Remove `plotgraphsScript.sh`.
- Added scripts;
1. SN post baryon density generator script from preSN file with added shockwave (`create_SN_tXsdat.py`).
2. Run script for random `ri_km` and `magneticField_polynomialDecayDistance` (`run_random_ri_magPolDecDist.py`).
- Added `holdIntermediateData` option to technical parameters `technicalParameters.dat`.
- Added new functions without holding intermediate data `RHS.py`.
- Adopted `diffSolvers.py` for new `holdIntermediateData` variable.
- Fixed in matter hamiltonian (wrong assignment of Ye and nb when reading data from a file.)
- Minor changes in `plotgraphs.py`.
- Add function to copy background profile to results folder (`writeFiles.py`, `collnuPy.py`).
- Change all "STATUS" strings/variables to "INFO" in all code.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
typical or common use of that class of product, regardless of the INFO
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
Expand Down
15 changes: 10 additions & 5 deletions collNuPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# ============================
# Colors For Printing
class tLog:
STATUS = '\033[94m'+'[STATUS] '+'\033[0m'
INFO = '\033[94m'+'[INFO] '+'\033[0m'
OK = '\033[92m'+'[OK] '+'\033[0m'
WARNING = '\033[93m'+'[WARNING] '+'\033[0m'
ERROR = '\033[91m'+'[ERROR] '+'\033[0m'
Expand All @@ -51,7 +51,7 @@ class tLog:
osCommand.makedirs(RESULTS_DIR)
print(tLog.OK+"Results Folder Created.")
else:
print(tLog.STATUS+"Results Folder Already Exists.")
print(tLog.INFO+"Results Folder Already Exists.")
# ============================

# ============================
Expand Down Expand Up @@ -95,14 +95,14 @@ class tLog:

# ============================
# Save final human readable data
# TODO: Comment out print after wrote the functions
# TODO: Comment out print after you wrote the functions
if init.technicalParametersDic['output_humanReadable']:
DATA_FOLDER_TXT= RESULTS_SIMULATION_DIR+ 'data/txt/'
if not osCommand.path.exists(DATA_FOLDER_TXT):
osCommand.makedirs(DATA_FOLDER_TXT)
print(tLog.OK+"TXT Data Folder Created.")
else:
print(tLog.STATUS+"TXT Data Folder Already Exists.")
print(tLog.INFO+"TXT Data Folder Already Exists.")
# ============================
# rhoFlavAll.txt
write2file.rhoFlavAll_txt(init,DATA_FOLDER_TXT+'rhoFlavAll.txt', rhoFlavAll)
Expand All @@ -121,6 +121,11 @@ class tLog:
#print(tLog.OK+"Saved: eigVal_eigVec.txt.")
# ============================

# ============================
# Copy background profile file(s)
write2file.saveBackgroundProfiles(init, COLLECTIVE_NU_OSC_DIR+'backgroundProfiles/', DATA_FOLDER_NPZ)
# ============================

# ============================
# Save final plots
if init.technicalParametersDic['plotGraphs']:
Expand All @@ -142,6 +147,6 @@ class tLog:
osCommand.system('find . | grep -E "(__pycache__|.pyc|.pyo$)" | xargs rm -rf')
print(tLog.OK+"Unused Files and Folders Removed.")
#! ============================
print(tLog.STATUS+'[FINISHED] =====> simulation'+str(simNum)+' <===== [FINISHED]\n')
print(tLog.INFO+'[FINISHED] =====> simulation'+str(simNum)+' <===== [FINISHED]\n')
exit()
# ============================
110 changes: 97 additions & 13 deletions modules/RHS.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# ============================
# Colors For Printing
class tLog:
STATUS = '\033[94m'+'[STATUS] '+'\033[0m'
INFO = '\033[94m'+'[INFO] '+'\033[0m'
OK = '\033[92m'+'[OK] '+'\033[0m'
WARNING = '\033[93m'+'[WARNING] '+'\033[0m'
ERROR = '\033[91m'+'[ERROR] '+'\033[0m'
Expand All @@ -22,6 +22,20 @@ class tLog:
# ============================
# RHS For Neutrinos f(r,rho) !!Only LSODA!!
# Two Flavor
def rhs2Flav_noInterData(rhoAll, dist):
# ============================
# Define the RHS
totHamAP = hamil.hamiltonian(rhoAll, dist).totalHam2Flav_km_1()
# rhoAll must be in the form of [2, energyMod, totFlav*2, totFlav*2]

# Total Hamiltionian (totHam) [2, energyMod, totFlav, totFlav]
# For neutrinos -> totHam[0]
# For antineutrinos -> totHam[1]

# Note: 3d array + 2d array gives a result that add all 2d array with each element of 3d array
# Take Commutator of density and Hamiltonian for each energy
return np.array([(-1j)* ((totHamAP[0] @ rhoAll[0])- (rhoAll[0] @ totHamAP[0]))\
, (-1j)*((totHamAP[1] @ rhoAll[1])- (rhoAll[1] @ totHamAP[1]))]).flatten()
def rhs2Flav(rhoAll, dist):
# ============================
# Show intermediate distance and hold the values
Expand All @@ -38,10 +52,10 @@ def rhs2Flav(rhoAll, dist):
# To show current time
currentTimeDate = datetime.datetime.now()
fileObject = open('distanceAndTime.log','a+')
# Do not color the [STATUS]
# Do not color the [INFO]
print('Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"), file=fileObject)
fileObject.close()
print(tLog.STATUS+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
print(tLog.INFO+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
# ============================

# ============================
Expand All @@ -58,6 +72,20 @@ def rhs2Flav(rhoAll, dist):
return np.array([(-1j)* ((totHamAP[0] @ rhoAll[0])- (rhoAll[0] @ totHamAP[0]))\
, (-1j)*((totHamAP[1] @ rhoAll[1])- (rhoAll[1] @ totHamAP[1]))]).flatten()
# Three Flavor
def rhs3Flav_noInterData(rhoAll, dist):
# ============================
# Define the RHS
totHamAP = hamil.hamiltonian(rhoAll, dist).totalHam3Flav_km_1()
# rhoAll must be in the form of [2, energyMod, totFlav*2, totFlav*2]

# Total Hamiltionian (totHam) [2, energyMod, totFlav, totFlav]
# For neutrinos -> totHam[0]
# For antineutrinos -> totHam[1]

# Note: 3d array + 2d array gives a result that add all 2d array with each element of 3d array
# Take Commutator of density and Hamiltonian for each energy
return np.array([(-1j)* ((totHamAP[0] @ rhoAll[0])- (rhoAll[0] @ totHamAP[0]))\
, (-1j)*((totHamAP[1] @ rhoAll[1])- (rhoAll[1] @ totHamAP[1]))]).flatten()
def rhs3Flav(rhoAll, dist):
# ============================
# Show intermediate distance and hold the values
Expand All @@ -74,10 +102,10 @@ def rhs3Flav(rhoAll, dist):
# To show current time
currentTimeDate = datetime.datetime.now()
fileObject = open('distanceAndTime.log','a+')
# Do not color the [STATUS]
# Do not color the [INFO]
print('Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"), file=fileObject)
fileObject.close()
print(tLog.STATUS+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
print(tLog.INFO+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
# ============================

# ============================
Expand All @@ -94,6 +122,20 @@ def rhs3Flav(rhoAll, dist):
return np.array([(-1j)* ((totHamAP[0] @ rhoAll[0])- (rhoAll[0] @ totHamAP[0]))\
, (-1j)*((totHamAP[1] @ rhoAll[1])- (rhoAll[1] @ totHamAP[1]))]).flatten()
# Four Flavor
def rhs4Flav_noInterData(rhoAll, dist):
# ============================
# Define the RHS
totHamAP = hamil.hamiltonian(rhoAll, dist).totalHam4Flav_km_1()
# rhoAll must be in the form of [2, energyMod, totFlav*2, totFlav*2]

# Total Hamiltionian (totHam) [2, energyMod, totFlav, totFlav]
# For neutrinos -> totHam[0]
# For antineutrinos -> totHam[1]

# Note: 3d array + 2d array gives a result that add all 2d array with each element of 3d array
# Take Commutator of density and Hamiltonian for each energy
return np.array([(-1j)* ((totHamAP[0] @ rhoAll[0])- (rhoAll[0] @ totHamAP[0]))\
, (-1j)*((totHamAP[1] @ rhoAll[1])- (rhoAll[1] @ totHamAP[1]))]).flatten()
def rhs4Flav(rhoAll, dist):
# ============================
# Show intermediate distance and hold the values
Expand All @@ -110,10 +152,10 @@ def rhs4Flav(rhoAll, dist):
# To show current time
currentTimeDate = datetime.datetime.now()
fileObject = open('distanceAndTime.log','a+')
# Do not color the [STATUS]
# Do not color the [INFO]
print('Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"), file=fileObject)
fileObject.close()
print(tLog.STATUS+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
print(tLog.INFO+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
# ============================

# ============================
Expand All @@ -134,6 +176,20 @@ def rhs4Flav(rhoAll, dist):
# ============================
# RHS For Neutrinos f(r,rho) !!Only LSODA!!
# Two Flavor
def rhs2Flav_bigRho_noInterData(rhoAll, dist):
# ============================
# Define the RHS
totHamAP = hamil.hamiltonian_BigRho(rhoAll, dist).totalHam2Flav_km_1()
# rhoAll must be in the form of [energyMod, totFlav*2, totFlav*2]
# Total Hamiltionian (totHam) [energyMod,totFlav*2,totFlav*2]
# totHam[N,0:totFlav,0:totFlav] => Neutrinos
# totHam[N,totFlav:totFlav*2,totFlav:totFlav*2] => Anti-Neutrinos
# totHam[N,0:totFlav,totFlav:totFlav*2] => Neutrino to Anti-neutrino

# Note: 3d array + 2d array gives a result that add all 2d array with each element of 3d array
# Take Commutator of density and Hamiltonian for each energy

return ((-1j)* ((totHamAP @ rhoAll)- (rhoAll @ totHamAP))).flatten()
def rhs2Flav_bigRho(rhoAll, dist):
# ============================
# Show intermediate distance and hold the values
Expand All @@ -150,10 +206,10 @@ def rhs2Flav_bigRho(rhoAll, dist):
# To show current time
currentTimeDate = datetime.datetime.now()
fileObject = open('distanceAndTime.log','a+')
# Do not color the [STATUS]
# Do not color the [INFO]
print('Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"), file=fileObject)
fileObject.close()
print(tLog.STATUS+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
print(tLog.INFO+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
# ============================

# ============================
Expand All @@ -170,6 +226,20 @@ def rhs2Flav_bigRho(rhoAll, dist):

return ((-1j)* ((totHamAP @ rhoAll)- (rhoAll @ totHamAP))).flatten()
# Three Flavor
def rhs3Flav_bigRho_noInterData(rhoAll, dist):
# ============================
# Define the RHS
totHamAP = hamil.hamiltonian_BigRho(rhoAll, dist).totalHam3Flav_km_1()
# rhoAll must be in the form of [energyMod, totFlav*2, totFlav*2]
# Total Hamiltionian (totHam) [energyMod,totFlav*2,totFlav*2]
# totHam[N,0:totFlav,0:totFlav] => Neutrinos
# totHam[N,totFlav:totFlav*2,totFlav:totFlav*2] => Anti-Neutrinos
# totHam[N,0:totFlav,totFlav:totFlav*2] => Neutrino to Anti-neutrino

# Note: 3d array + 2d array gives a result that add all 2d array with each element of 3d array
# Take Commutator of density and Hamiltonian for each energy

return ((-1j)* ((totHamAP @ rhoAll)- (rhoAll @ totHamAP))).flatten()
def rhs3Flav_bigRho(rhoAll, dist):
# ============================
# Show intermediate distance and hold the values
Expand All @@ -186,10 +256,10 @@ def rhs3Flav_bigRho(rhoAll, dist):
# To show current time
currentTimeDate = datetime.datetime.now()
fileObject = open('distanceAndTime.log','a+')
# Do not color the [STATUS]
# Do not color the [INFO]
print('Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"), file=fileObject)
fileObject.close()
print(tLog.STATUS+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
print(tLog.INFO+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
# ============================

# ============================
Expand All @@ -206,6 +276,20 @@ def rhs3Flav_bigRho(rhoAll, dist):

return ((-1j)* ((totHamAP @ rhoAll)- (rhoAll @ totHamAP))).flatten()
# Four Flavor
def rhs4Flav_bigRho_noInterData(rhoAll, dist):
# ============================
# Define the RHS
totHamAP = hamil.hamiltonian_BigRho(rhoAll, dist).totalHam4Flav_km_1()
# rhoAll must be in the form of [energyMod, totFlav*2, totFlav*2]
# Total Hamiltionian (totHam) [energyMod,totFlav*2,totFlav*2]
# totHam[N,0:totFlav,0:totFlav] => Neutrinos
# totHam[N,totFlav:totFlav*2,totFlav:totFlav*2] => Anti-Neutrinos
# totHam[N,0:totFlav,totFlav:totFlav*2] => Neutrino to Anti-neutrino

# Note: 3d array + 2d array gives a result that add all 2d array with each element of 3d array
# Take Commutator of density and Hamiltonian for each energy

return ((-1j)* ((totHamAP @ rhoAll)- (rhoAll @ totHamAP))).flatten()
def rhs4Flav_bigRho(rhoAll, dist):
# ============================
# Show intermediate distance and hold the values
Expand All @@ -222,10 +306,10 @@ def rhs4Flav_bigRho(rhoAll, dist):
# To show current time
currentTimeDate = datetime.datetime.now()
fileObject = open('distanceAndTime.log','a+')
# Do not color the [STATUS]
# Do not color the [INFO]
print('Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"), file=fileObject)
fileObject.close()
print(tLog.STATUS+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
print(tLog.INFO+'Current distance is %.7f' % dist, 'km and time :', currentTimeDate.strftime("%Y-%m-%d %H:%M:%S"))
# ============================

# ============================
Expand Down
Loading

0 comments on commit 4d39b62

Please sign in to comment.