Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
55 changes: 27 additions & 28 deletions massive_star/15m_500_sec.aprox19.dat
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# npts = 3611
# number of variables = 27
density
temperature
ye
velx
pressure
entr
abar
enuc
n
H1
p
He3
He4
C12
N14
O16
Ne20
Mg24
Si28
S32
Ar36
Ca40
Ti44
Cr48
Fe52
Fe54
Ni56
# density
# temperature
# ye
# velx
# pressure
# entr
# abar
# enuc
# n
# H1
# p
# He3
# He4
# C12
# N14
# O16
# Ne20
# Mg24
# Si28
# S32
# Ar36
# Ca40
# Ti44
# Cr48
# Fe52
# Fe54
# Ni56
337537.71121300000232 1808953118.9500000477 6584485414.5799999237 0.46354931956700001772 -119.34958673799999929 1.0507722924199999529e+27 0.85488876350700004902 51.959996281300000476 10717328463399999488 0.0012822561731099999232 0 8.734243857490000473e-08 0 0.00055562984419200002559 3.5976537168900001507e-09 0 7.9770873314700001431e-10 2.5784726164900001073e-12 2.784609616930000066e-11 1.0159525520600000283e-09 1.5988627581300000157e-10 1.8389748363700000301e-11 3.5904618100499999432e-12 3.0906166241799997709e-14 2.7972765513299999597e-14 2.4717986882499998539e-14 2.603937801570000207e-06 0.99815941707886168821
594047.20889500004705 1808775668.3699998856 6584256849.8100004196 0.46354956795199997455 -150.37372296300000585 1.0506333147799999863e+27 0.85488120579199999849 51.961420944099998565 -3028276060670000128 0.001281773310189999928 0 8.7287310247000001032e-08 0 0.00055539992557500003894 3.594294609229999968e-09 0 7.969471086430000436e-10 2.5755498214499998767e-12 2.7817658838999998508e-11 1.0150651159099999464e-09 1.5974328974399999034e-10 1.8372255479600000789e-11 3.5869898665700002016e-12 3.0871376680500002269e-14 2.7942324735400000559e-14 2.4692991233799999298e-14 2.6028843046100000086e-06 0.99816013097389177933
832856.79917100002058 1808546203.4000000954 6584382058.4099998474 0.46354961633300001411 -189.46412342799999351 1.0504678768300000408e+27 0.85492014537299998445 51.961226871800000993 27715722773700001792 0.0012817750373099998963 0 8.7383507065000006563e-08 0 0.00055570183621600000631 3.598040236700000117e-09 0 7.9785030440799997164e-10 2.5789263096800000188e-12 2.7854509254399999653e-11 1.0164074134999999535e-09 1.5997014328799999378e-10 1.8400719411899998846e-11 3.5929843078699998736e-12 3.0929638242799998024e-14 2.7998417638099998454e-14 2.4744858893900000256e-14 2.6054742517499999882e-06 0.99815982464369179539
Expand Down Expand Up @@ -3638,4 +3638,3 @@ Ni56
63436906460500 2.1977853600099999171e-09 3168.5209801699998025 0.82242463736199999946 2015.2893995800000084 419.88098907900001677 20.322542062800000195 1.3700919410100000917 2.7360769874299997925e-28 1.0035163404800000013e-99 0.64495034955999996917 1.0035163404800000013e-99 1.9571546147100000226e-05 0.33498340974800000502 0.0020667958887200001128 0.0040157717779699996299 0.0079674516039400008344 0.0021288213024800001737 0.00081081192470599996319 0.00089476020801399999173 0.00044591876249999999778 8.8048009653300004476e-05 7.8728240015199998383e-05 1.4923075529999999622e-68 1.0035163404800000013e-99 1.0035163404800000013e-99 8.9681194949700002985e-05 0.0014598802325300000177
63436906470600 2.1977853541799999406e-09 3168.5209792800001196 0.82242463736399995522 2015.2768581400000585 419.88098784499999283 20.322542064400000328 1.3700919410100000917 2.7360769802199999217e-28 1.0035163404800000013e-99 0.64495034956499996959 1.0035163404800000013e-99 1.9571546147700001096e-05 0.33498340974300000461 0.002066795888779999861 0.0040157717778000001987 0.0079674516040600003308 0.0021288213024800001737 0.00081081192470599996319 0.00089476020801399999173 0.00044591876249999999778 8.8048009653300004476e-05 7.8728240015199998383e-05 1.4923075527700000884e-68 1.0035163404800000013e-99 1.0035163404800000013e-99 8.9681194949700002985e-05 0.0014598802325300000177
63436906475700 2.1977853522400000151e-09 3168.520978980000109 0.822424637366000022 2015.2768581400000585 419.88098743400001922 20.322542065000000377 1.3700919410000000909 2.7360769778199998534e-28 1.0035163404800000013e-99 0.64495034956899999212 1.0035163404800000013e-99 1.9571546148100000547e-05 0.33498340974000001546 0.0020667958888199999823 0.0040157717776700000215 0.0079674516041400005734 0.0021288213024800001737 0.00081081192470599996319 0.00089476020801399999173 0.00044591876249999999778 8.8048009653300004476e-05 7.8728240015199998383e-05 1.4923075525900000887e-68 1.0035163404800000013e-99 1.0035163404800000013e-99 8.9681194949700002985e-05 0.0014598802325300000177
# conversion of 15m_500_sec.txt to aprox19 nuclei via convert_21_to_19.py
5 changes: 1 addition & 4 deletions massive_star/convert_21_to_19.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,8 @@
for name in names_new:
if name == "r":
continue
f.write(f"{name}\n")
f.write(f"# {name}\n")
for irow in range(data_new.shape[0]):
l = [f"{q:30.20g}" for q in data_new[irow, :]]
f.write(" ".join(l) + "\n")

f.write(f"# conversion of {file} to aprox19 nuclei via convert_21_to_19.py\n")


99 changes: 78 additions & 21 deletions read_model.H
Original file line number Diff line number Diff line change
Expand Up @@ -157,29 +157,75 @@ read_file(const std::string filename, initial_model_t& initial_model) {

std::string line;

// first the header line -- this tells us the number of points
// first the header line -- this will determine the format. If it
// tells us the number of points (npts), then we are the old style.

getline(mf, line);
std::string npts_string = line.substr(line.find("=")+1, line.length());
initial_model.npts = std::stoi(npts_string);

if (initial_model.npts > NPTS_MODEL) {
amrex::Error("Error: model has more than NPTS_MODEL points,");
}
int nvars_model_file;
std::vector<std::string> varnames_stored;

// next line tells use the number of variables
if (line.find("npts") != std::string::npos || line.find("number of points") != std::string::npos) {
// old format. example:
/*
# npts = 3
# number of variables = 2
# radius
# density
# temperature
0.1 3 4.0
0.2 4 3.9
0.3 4 3.7
*/

// ignore the first line, and detect the number of points
// automatically below

// next line tells use the number of variables

getline(mf, line);
std::string num_vars_string = line.substr(line.find("=")+1, line.length());
int nvars_model_file = std::stoi(num_vars_string);
getline(mf, line);

// now read in the names of the variables
if (line.find("num of variables") == std::string::npos && line.find("number of variables") == std::string::npos) {
amrex::Error("Error: missing the number of variables header");
}

std::vector<std::string> varnames_stored;
for (int n = 0; n < nvars_model_file; n++) {
getline(mf, line);
std::string var_string = line.substr(line.find("#")+1, line.length());
varnames_stored.push_back(model_string::ltrim(model_string::rtrim(var_string)));
std::string num_vars_string = line.substr(line.find("=")+1, line.length());
nvars_model_file = std::stoi(num_vars_string);

// now read in the names of the variables

for (int n = 0; n < nvars_model_file; n++) {
getline(mf, line);
std::string var_string = line.substr(line.find("#")+1, line.length());
varnames_stored.push_back(model_string::ltrim(model_string::rtrim(var_string)));
}
} else {
// new format. example:
/*
# radius density temperature
0.1 3 4.0
0.2 4 3.9
0.3 4 3.7
*/

// remove the leading "#"
if (!line.empty() && line[0] == '#') {
line = line.substr(1);
}

std::istringstream iss(line);

// in this format, the first column name is the coordinate --
// we can skip that

std::string word;
iss >> word;

while (iss >> word) {
varnames_stored.push_back(word);
}

nvars_model_file = static_cast<int>(varnames_stored.size());
}


Expand All @@ -188,11 +234,17 @@ read_file(const std::string filename, initial_model_t& initial_model) {
amrex::Vector<Real> vars_stored;
vars_stored.resize(nvars_model_file);

for (int i = 0; i < initial_model.npts; i++) {
mf >> initial_model.r(i);
int i{0};
while (getline(mf, line)) {
if (i > NPTS_MODEL) {
amrex::Error("Error: model has more than NPTS_MODEL points. Increase MAX_NPTS_MODEL");
}

std::istringstream iss(line);
iss >> initial_model.r(i);

for (int j = 0; j < nvars_model_file; j++) {
mf >> vars_stored[j];
iss >> vars_stored[j];
}

for (int j = 0; j < model::nvar; j++) {
Expand Down Expand Up @@ -238,9 +290,14 @@ read_file(const std::string filename, initial_model_t& initial_model) {
amrex::Print() << Font::Bold << FGColor::Yellow << "[WARNING] variable not found: " << varnames_stored[j] << ResetDisplay << std::endl;
}

} // end loop over nvars_model_file
} // end loop over variables in line

}
i++;
} // end of loop over lines in model file

initial_model.npts = i;

mf.close();
}

#endif