|
| 1 | +/* |
| 2 | +This program computes the ignition condition of the X-ray burst |
| 3 | +based on https://github.com/andrewcumming/settle |
| 4 | +See DOI: 10.1086/317191 for details. |
| 5 | +
|
| 6 | +Usage: |
| 7 | +./main.ex <X> <Z> <Fb> <mdot> <COMPRESS> |
| 8 | +
|
| 9 | +Fb: Base Flux in MeV/nucleon |
| 10 | +X: Hydrogen massfraction |
| 11 | +Z: CNO massfraction |
| 12 | +mdot: Local accretion rate in Eddington unit |
| 13 | +COMPRESS: To include compressional heating or not. |
| 14 | +*/ |
| 15 | + |
| 16 | +#include <iostream> |
| 17 | +#include <AMReX_Real.H> |
| 18 | + |
| 19 | +struct State |
| 20 | +{ |
| 21 | + // Radius and gravitational acceleration |
| 22 | + amrex::Real R, g; |
| 23 | + |
| 24 | + // Initial abundance for hydrogen, helium, and metal |
| 25 | + amrex::Real X, Y, Z; |
| 26 | + |
| 27 | + // Accretion rate |
| 28 | + amrex::Real mdot; |
| 29 | + |
| 30 | + // Depletion Column Depth |
| 31 | + amrex::Real yd; |
| 32 | + |
| 33 | + // Top boundary column depth, temperature and flux |
| 34 | + amrex::Real yt, Tt, Ft; |
| 35 | + |
| 36 | + // Bot boundary column depth, temperature and flux |
| 37 | + // This is assumed to be the ignition condition |
| 38 | + amrex::Real yb, Tb, Fb; |
| 39 | +}; |
| 40 | + |
| 41 | + |
| 42 | +void yb_constraint_eq(State& state, amrex::Real yb_0) { |
| 43 | + // Constraint equation to find ignition column depth |
| 44 | + // given the guess ignition column depth, yb_0. |
| 45 | + // Note the guess value is given in log10(yb) |
| 46 | + |
| 47 | + state.yb = std::pow(10.0, yb_0); |
| 48 | + |
| 49 | + // Set the upper boundary conditions: yt, Tt, and Ft |
| 50 | + |
| 51 | + // Pick arbitrary top boundary column depth |
| 52 | + // Follow "settle" version on Github |
| 53 | + state.yt = 1.e3_rt; |
| 54 | + |
| 55 | + // Compute the top boundary flux |
| 56 | + // Ft = F_b + epsilon_H * (yb or yd) |
| 57 | + // which ever is smaller. |
| 58 | + // If yb < yd, the ignition happens during hydrogen-helium layer |
| 59 | + // If yb > yd, the ignition happens during pure helium layer |
| 60 | + |
| 61 | + amrex::Real epsilon_H = 5.8e13 * (state.Z / 0.01); |
| 62 | + state.Ft = state.Fb + epsilon_H * std::min(state.yb, state.yd); |
| 63 | + |
| 64 | + // Compute the top boundary temperature |
| 65 | + // Given by the analytic radiative zero solution for constant flux |
| 66 | + // Tt = (3 κ Ft yt/ [a c]) |
| 67 | +} |
| 68 | + |
| 69 | + |
| 70 | +void find_yb() { |
| 71 | + // |
| 72 | +} |
| 73 | + |
| 74 | + |
| 75 | +int main(int argc, char* argv[]) { |
| 76 | + |
| 77 | + // state contains all information about the ignition conditions |
| 78 | + State state; |
| 79 | + |
| 80 | + // Gravitational Acceleration for 1.4 solar mass and 11 km NS. |
| 81 | + state.g = 1.5e14_rt; |
| 82 | + state.R = 1.1e6_rt; |
| 83 | + |
| 84 | + // Check if we have enough arguments passed in |
| 85 | + if (argc < 5) { |
| 86 | + std::cout << "Error" << std::endl; |
| 87 | + } |
| 88 | + |
| 89 | + // Read in input parameters: X, Z, mdot, and F_b |
| 90 | + |
| 91 | + state.X = std::stod(argv[0]); |
| 92 | + state.Z = std::stod(argv[1]); |
| 93 | + |
| 94 | + // Compute the Eddington Accretion Rate |
| 95 | + // mdot_Edd = 2 m_p c / [(1 + X) R σ_th ] |
| 96 | + // They used a value of 8.8e4 g cm^-2 s^-1 |
| 97 | + // We can compute it at runtime in the future |
| 98 | + amrex::Real mdot_Edd = 8.8e4_rt; // Come back later |
| 99 | + |
| 100 | + state.mdot = std::stod(argv[2]) * m_Edd; |
| 101 | + |
| 102 | + // Input Fb is MeV/nucleon/mdot. |
| 103 | + // Brown & Bildstein showed that electron capture rates can |
| 104 | + // release ~ 1 MeV/nucleon deep in the crust |
| 105 | + // The compressional term can give additional c_p T ~ 20 T8 keV/nucleon |
| 106 | + // If don't include compressional term, use higher constant Fb |
| 107 | + // to account for compressional heating. They use ~1.5 MeV/nucleon |
| 108 | + // Convert to CGS. |
| 109 | + state.Fb = std::stod(argv[3]) * state.mdot * 14.62_rt * 5.8e21_rt; // Not sure why multiplied by these constants, supposedly it is to convert to CGS... |
| 110 | + |
| 111 | + // Get the initial helium mass fraction |
| 112 | + state.Y = 1.0_rt - state.X - state.Z; |
| 113 | + |
| 114 | + // Energy release per gram from hot CNO. |
| 115 | + // This is mass difference between helium and 4 hydrogen |
| 116 | + constexpr amrex::Real E_H = 6.4e18_rt; |
| 117 | + |
| 118 | + // Specific nuclear energy generation rate for hot CNO |
| 119 | + amrex::Real epsilon_H = 5.8e13 * (state.Z / 0.01); |
| 120 | + |
| 121 | + // Depletion Column Depth: yd = X mdot E_H / epsilon_H |
| 122 | + state.yd = state.X * state.mdot * E_H / epsilon_H; |
| 123 | + |
| 124 | + // Now compute the base column depth: yb |
| 125 | + // This is also the ignition column depth |
| 126 | + // Assume that we work with log10(yb) |
| 127 | + |
| 128 | + state.yb = find_yb(); |
| 129 | +} |
0 commit comments