Skip to content

Commit

Permalink
Update test code in supernovaia.cpp and scripts in testonestar.
Browse files Browse the repository at this point in the history
  • Loading branch information
trquinn committed May 23, 2024
1 parent 515770c commit c32b642
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 9 deletions.
19 changes: 12 additions & 7 deletions supernovaia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,19 @@ double SN::NSNIa (double dMassT1, double dMassT2) const
int
main(int argc, char **argv)
{
Chabrier chimf; // Chabrier has power law index of -1.3 which
// Chabrier chimf; // Chabrier has power law index of -1.3 which
// matches s = -2.35 in Greggio & Renzini, 1983
// Kroupa93 chimf; // Kroupa is what RVN use.
// Kroupa01 chimf;
Kroupa01 chimf;
// MillerScalo chimf;
SN sn;
sn.imf = &chimf;
Padova pdva;
Rand rndGen;
double z = 0.02; // metalicity: use value to compare
// with Greggio & Renzini, 1983

double nsamp = 100;
double nsamp = 1000;
double tfac = log(14.0e9/1e6)/nsamp; /// equal log interavals from 1Myr
/// to 14Gyr

Expand All @@ -109,19 +110,23 @@ main(int argc, char **argv)
double dMFeII = 0.0;
double dMOxIa = 0.0;
double dMFeIa = 0.0;
double dESNII = 0.0;
double dESNIa = 0.0;

deltat = 1e6;
for (int i = 0; i < 10000; i++) {
t = i*deltat;
sn.CalcSNIIFeedback(&sfEvent, t, deltat, &fbEffectsII);
sn.CalcSNIIFeedback(&sfEvent, t, deltat, &fbEffectsII, rndGen);
dMOxII += fbEffectsII.dMassLoss*fbEffectsII.dMOxygen;
dMFeII += fbEffectsII.dMassLoss*fbEffectsII.dMIron;
dESNII += fbEffectsII.dMassLoss*fbEffectsII.dEnergy;
sn.CalcSNIaFeedback(&sfEvent, t, deltat, &fbEffectsIa);
dMOxIa += fbEffectsIa.dMassLoss*fbEffectsIa.dMOxygen;
dMFeIa += fbEffectsIa.dMassLoss*fbEffectsIa.dMIron;
dESNIa += fbEffectsIa.dMassLoss*fbEffectsIa.dEnergy;
}
printf("# Total II Ox: %g, Fe: %g\n", dMOxII, dMFeII);
printf("# Total Ia Ox: %g, Fe: %g\n", dMOxIa, dMFeIa);
printf("# Total II Ox: %g, Fe: %g, E: %g\n", dMOxII, dMFeII, dESNII);
printf("# Total Ia Ox: %g, Fe: %g, E: %g\n", dMOxIa, dMFeIa, dESNIa);
}

for(int i = 0; i < nsamp; i++) {
Expand All @@ -146,7 +151,7 @@ main(int argc, char **argv)
}
else dNSNII = 0.0;

sn.CalcSNIIFeedback(&sfEvent, t, deltat, &fbEffectsII);
sn.CalcSNIIFeedback(&sfEvent, t, deltat, &fbEffectsII, rndGen);
sn.CalcSNIaFeedback(&sfEvent, t, deltat, &fbEffectsIa);

if (dMaxMass > dMinMass)
Expand Down
10 changes: 8 additions & 2 deletions testonestar/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CXXFLAGS = -g -O0 -DSNIA_TST -I.. -I../../utility/structures -DCOOLING_NONE -Wall
CXXFLAGS = -g -O0 -DSNIA_TST -DWENDLAND -I.. -I../../utility/structures -DCOOLING_NONE -Wall -I/usr/include/tirpc
CXX=../../charm/bin/charmc
CHARMC=$(CXX)
LDFLAGS = -g -language charm++ ../romberg.o
Expand All @@ -12,9 +12,15 @@ imf: imf.o
imf.o: imf.cpp ../imf.h testimf.decl.h

supernovaia: supernovaia.o imf.o starlifetime.o supernova.o
$(CXX) $(LDFLAGS) supernovaia.o imf.o starlifetime.o supernova.o -o supernovaia
$(CXX) $(LDFLAGS) supernovaia.o imf.o starlifetime.o supernova.o -lck -lconverse -o supernovaia

supernovaia.o: supernovaia.cpp ../imf.h testsnia.decl.h

clean:
rm -f *.o supernovaia *.decl.h *.def.h onestar.000130* onestar.starlog
rm -f onestar.log onestar.timings onestar.out lastcheckpoint
rm -f SNII.out SNIa.out winds.out eff.out
rm -rf onestar.chk?

%.decl.h %.def.h : %.ci
$(CHARMC) $<
14 changes: 14 additions & 0 deletions testonestar/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This directory contains tests of the feedback and associated stellar
evolution. The test simulation is a single star (actually stellar population)
in a cloud of gas, that is run for 13 Gyr.

run.sh shows the basic script to run the test with ChaNGa. "metalcheck.sh"
extracts needed information into a number of files and then runs an IDL
script to perform the check.

"metals.awk" and "energy.awk" are other helper scripts to do checks on the
output.

Makefile also can build a standalone test for supernovaia that shows
overall supernova output based on the modules used in ChaNGa.

22 changes: 22 additions & 0 deletions testonestar/energy.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# script to sum up all the feedbacks in onestar.out
#
# Run with "awk -f energy.awk < onestar.out"
#
BEGIN {
total_fb0 = 0.0;
total_fb1 = 0.0;
total_fb2 = 0.0;
}

# order is SNII, SNIa, Wind
/feedback 0:/ { total_fb0 += $4; }
/feedback 1:/ { total_fb1 += $4; }
/feedback 2:/ { total_fb2 += $4; }

END {
print "Total SNII Energy: ", total_fb0;
print "Total SNIa Energy: ", total_fb1;
print "Total Wind Energy: ", total_fb2;
print "Total Energy: ", total_fb0 + total_fb1 + total_fb2;
}

0 comments on commit c32b642

Please sign in to comment.