|
| 1 | +# a blend of CNO_extras and subch_simple |
| 2 | + |
| 3 | +import pynucastro as pyna |
| 4 | +from pynucastro.networks import AmrexAstroCxxNetwork |
| 5 | + |
| 6 | +DO_DERIVED_RATES = False |
| 7 | + |
| 8 | +def get_library(): |
| 9 | + |
| 10 | + reaclib_lib = pyna.ReacLibLibrary() |
| 11 | + |
| 12 | + all_reactants = ["h1", "he4", |
| 13 | + "c12", "c13", |
| 14 | + "n13", "n14", "n15", |
| 15 | + "o14", "o15", "o16", "o17", "o18", |
| 16 | + "f17", "f18", "f19", |
| 17 | + "ne18", "ne19", "ne20", "ne21", |
| 18 | + "na22", "na23", |
| 19 | + "mg22", "mg24", |
| 20 | + "al27", "si28", "p31", "s32", |
| 21 | + "cl35", "ar36", "k39", "ca40", |
| 22 | + "sc43", "ti44", "v47", "cr48", |
| 23 | + "mn51", "fe52", "co55", "ni56"] |
| 24 | + |
| 25 | + subch = reaclib_lib.linking_nuclei(all_reactants) |
| 26 | + |
| 27 | + # in this list, we have the reactants, the actual reactants, |
| 28 | + # and modified products that we will use instead |
| 29 | + other_rates = [("c12(c12,n)mg23", "mg24"), |
| 30 | + ("o16(o16,n)s31", "s32"), |
| 31 | + ("o16(c12,n)si27", "si28")] |
| 32 | + |
| 33 | + for r, mp in other_rates: |
| 34 | + _r = reaclib_lib.get_rate_by_name(r) |
| 35 | + _r.modify_products(mp) |
| 36 | + subch += pyna.Library(rates=[_r]) |
| 37 | + |
| 38 | + # finally, the aprox nets don't include the reverse rates for |
| 39 | + # C12+C12, C12+O16, and O16+O16, so remove those |
| 40 | + |
| 41 | + for r in subch.get_rates(): |
| 42 | + if sorted(r.products) in [[pyna.Nucleus("c12"), pyna.Nucleus("c12")], |
| 43 | + [pyna.Nucleus("c12"), pyna.Nucleus("o16")], |
| 44 | + [pyna.Nucleus("o16"), pyna.Nucleus("o16")]]: |
| 45 | + subch.remove_rate(r) |
| 46 | + |
| 47 | + # C12+Ne20 and reverse |
| 48 | + # (a,g) links between Na23 and Al27 |
| 49 | + # (a,g) links between Al27 and P31 |
| 50 | + |
| 51 | + rates_to_remove = ["p31(p,c12)ne20", |
| 52 | + "si28(a,c12)ne20", |
| 53 | + "ne20(c12,p)p31", |
| 54 | + "ne20(c12,a)si28", |
| 55 | + "na23(a,g)al27", |
| 56 | + "al27(g,a)na23", |
| 57 | + "al27(a,g)p31", |
| 58 | + "p31(g,a)al27"] |
| 59 | + |
| 60 | + for r in rates_to_remove: |
| 61 | + print("removing: ", r) |
| 62 | + _r = subch.get_rate_by_name(r) |
| 63 | + subch.remove_rate(_r) |
| 64 | + |
| 65 | + if DO_DERIVED_RATES: |
| 66 | + rates_to_derive = [] |
| 67 | + for r in subch.get_rates(): |
| 68 | + if r.reverse: |
| 69 | + # this rate was computed using detailed balance, regardless |
| 70 | + # of whether Q < 0 or not. We want to remove it and then |
| 71 | + # recompute it |
| 72 | + rates_to_derive.append(r) |
| 73 | + |
| 74 | + # now for each of those derived rates, look to see if the pair exists |
| 75 | + |
| 76 | + for r in rates_to_derive: |
| 77 | + fr = subch.get_rate_by_nuclei(r.products, r.reactants) |
| 78 | + if fr: |
| 79 | + print(f"modifying {r} from {fr}") |
| 80 | + subch.remove_rate(r) |
| 81 | + d = pyna.DerivedRate(rate=fr, compute_Q=False, use_pf=True) |
| 82 | + subch.add_rate(d) |
| 83 | + |
| 84 | + return subch |
| 85 | + |
| 86 | +def doit(): |
| 87 | + |
| 88 | + subch = get_library() |
| 89 | + |
| 90 | + # these are the rates that we are going to allow to be optionally |
| 91 | + # zeroed |
| 92 | + r1 = subch.get_rate_by_name("c12(p,g)n13") |
| 93 | + r2 = subch.get_rate_by_name("n13(he4,p)o16") |
| 94 | + |
| 95 | + net = AmrexAstroCxxNetwork(libraries=[subch], symmetric_screening=True, disable_rate_params=[r1, r2]) |
| 96 | + net.make_ap_pg_approx(intermediate_nuclei=["cl35", "k39", "sc43", "v47", "mn51", "co55"]) |
| 97 | + net.remove_nuclei(["cl35", "k39", "sc43", "v47", "mn51", "co55"]) |
| 98 | + |
| 99 | + # finally, the aprox nets don't include the reverse rates for |
| 100 | + # C12+C12, C12+O16, and O16+O16, so remove those |
| 101 | + |
| 102 | + print(f"number of nuclei: {len(net.unique_nuclei)}") |
| 103 | + print(f"number of rates: {len(net.rates)}") |
| 104 | + |
| 105 | + comp = pyna.Composition(net.get_nuclei()) |
| 106 | + comp.set_all(0.1) |
| 107 | + comp.set_nuc("he4", 0.95) |
| 108 | + comp.normalize() |
| 109 | + |
| 110 | + rho = 1.e6 |
| 111 | + T = 1.e9 |
| 112 | + |
| 113 | + net.plot(rho, T, comp, outfile="CNO_He_burn.png", |
| 114 | + rotated=True, hide_xalpha=True, curved_edges=True, |
| 115 | + size=(1500, 450), |
| 116 | + node_size=500, node_font_size=11, node_color="#337dff", node_shape="s", |
| 117 | + Z_range=(1,29)) |
| 118 | + |
| 119 | + net.write_network() |
| 120 | + |
| 121 | + |
| 122 | +if __name__ == "__main__": |
| 123 | + doit() |
0 commit comments