Skip to content

Commit

Permalink
Remove redundant rho-T columns from parsed ASCII format.
Browse files Browse the repository at this point in the history
+ Remove rho-T parsing from MeanOpacity loadASCII function.
+ Update test ASCII data file example_ascii/kap_plaw.txt.

Note: non-uniform rho-T data points can be interpolated onto
a log-log grid, e.g., with example_ascii/preproc_ascii_opac.py.
  • Loading branch information
RyanWollaeger committed Nov 20, 2024
1 parent 468e04c commit 9762081
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 32 deletions.
32 changes: 16 additions & 16 deletions singularity-opac/photons/example_ascii/kap_plaw.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
NRho 4 NT 4
rho_min 1.00000000e-14 rho_max 7.94328235e-01
T_min 1.00000000e+00 T_max 7.94328235e+06
1.00000000e-14 1.00000000e+00 1.00000000e-03 1.00000000e-01
1.00000000e-14 1.99526232e+02 1.00000000e-03 1.00000000e-01
1.00000000e-14 3.98107171e+04 1.00000000e-03 1.00000000e-01
1.00000000e-14 7.94328235e+06 1.00000000e-03 1.00000000e-01
4.29866235e-10 1.00000000e+00 1.00000000e-03 1.00000000e-01
4.29866235e-10 1.99526232e+02 1.00000000e-03 1.00000000e-01
4.29866235e-10 3.98107171e+04 1.00000000e-03 1.00000000e-01
4.29866235e-10 7.94328235e+06 1.00000000e-03 1.00000000e-01
1.84784980e-05 1.00000000e+00 1.00000000e-03 1.00000000e-01
1.84784980e-05 1.99526232e+02 1.00000000e-03 1.00000000e-01
1.84784980e-05 3.98107171e+04 1.00000000e-03 1.00000000e-01
1.84784980e-05 7.94328235e+06 1.00000000e-03 1.00000000e-01
7.94328235e-01 1.00000000e+00 1.00000000e-03 1.00000000e-01
7.94328235e-01 1.99526232e+02 1.00000000e-03 1.00000000e-01
7.94328235e-01 3.98107171e+04 1.00000000e-03 1.00000000e-01
7.94328235e-01 7.94328235e+06 1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
1.00000000e-03 1.00000000e-01
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
hdr = "NRho "+str(NRho)+" NT "+str(NT) + "\n" \
"rho_min {:.8e}".format(r[0])+" rho_max {:.8e}".format(r[NRho-1]) + "\n" \
"T_min {:.8e}".format(tt[0]) + " T_max {:.8e}".format(tt[NT-1])
np.savetxt(args.fname_new, opac, delimiter=" ", header=hdr, comments=" ", fmt="%.8e")
np.savetxt(args.fname_new, opac[:,2:], delimiter=" ", header=hdr, comments=" ", fmt="%.8e")

#--------------------------------------------------------------------------------------------------#
# End of preproc_ascii_opac.py
Expand Down
15 changes: 0 additions & 15 deletions singularity-opac/photons/mean_opacity_photons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,7 @@ class MeanOpacity {
cfline = const_cast<char*>(fline.c_str());
fl_tok = std::strtok(cfline, " ");

// check for consistent density [g/cm^3] on table row
const Real Rho = std::stod(fl_tok);
if (std::abs(Rho - fromLog_(lRho_i)) > 1e-6 * std::abs(Rho)) {
OPAC_ERROR("photons::MeanOpacity: invalid rho");
}

// check for consistent temperature [K] on table row
const Real lT_i = lkappa_.range(1).x(iT);
fl_tok = std::strtok(nullptr, " ");
const Real T = std::stod(fl_tok);
if (std::abs(T - fromLog_(lT_i)) > 1e-6 * std::abs(T)) {
OPAC_ERROR("photons::MeanOpacity: invalid T");
}

// populate Rosseland opacity [cm^2/g]
fl_tok = std::strtok(nullptr, " ");
lkappa_(iRho, iT, 0) = toLog_(std::stod(fl_tok));

// populate Planck opacity [cm^2/g]
Expand Down

0 comments on commit 9762081

Please sign in to comment.