pynucastro.rates.approximate_rates module#
- class pynucastro.rates.approximate_rates.ApproximateRate(primary_rate, secondary_rates, primary_reverse, secondary_reverse, *, is_reverse=False, approx_type='ap_pg', use_identical_particle_factor=True)[source]#
Bases:
Rate
An approximation to a rate sequence. Two approximations are currently supported:
“ap_pg” : combine the A(a, g)B and A(a, p)X(p, g)B sequences into a single, effective A(a, g)B rate.
“nn_g” : replace the sequence A(n, g)X(n, g)B with an effective A(nn, g)B rate.
This class stores all of the rates needed to implement these approximations.
- Parameters:
primary_rate (Rate) – An existing rate that represents the same sequence as the approximation we are creating. For “ap_pg”, this would be A(a, g)B. For “nn_g”, there is no unapproximated counterpart so we would pass in
None
.secondary_rates (list(Rate)) – A list of
Rate
objects containing all of the other forward rates needed to make the approximation.primary_reverse (Rate) – An existing rate that represents the reverse of the same approximation we are creating. For “ap_pg”, this would be B(g, a)A. For “nn_g”, there is no unapproximated counterpart, so we would pass in
None
.secondary_reverse (list(Rate)) – A list of
Rate
objects containing all of the other reverse rates needed to make the approximation.is_reverse (bool) – Are we creating the effective A(x,y)B or B(y, x)A?
approx_type (str) – The type of approximation to do. Currently supported are “ap_pg” and “nn_g”
use_identical_particle_factor (bool) – Usually if a rate has 2 reactants of the same type, we divide by 2, since the order doesn’t matter. However, for some approximations, like A(n,g)X(n,g)B -> A(nn,g), we don’t want this factor, since the neutron captures are sequential. This option allows the double counting factor to be disabled.
- eval(T, *, rho=None, comp=None)[source]#
Evaluate the approximate rate.
- Parameters:
T (float) – the temperature to evaluate the rate at
rho (float) – the density to evaluate the rate at
comp (Composition) – the composition to evaluate the rate with
- Return type:
- function_string_cxx(dtype='double', specifiers='inline', leave_open=False, extra_args=None)[source]#
Return a string containing the C++ function that computes the approximate rate
- Parameters:
dtype (str) – The C++ datatype to use for all declarations
specifiers (str) – C++ specifiers to add before each function declaration (i.e. “inline”)
leave_open (bool) – If
true
, then we leave the function unclosed (no “}” at the end). This can allow additional functions to add to this output.extra_args (list(str)) – A list of strings representing additional arguments that should be appended to the argument list when defining the function interface.
- Return type:
- pynucastro.rates.approximate_rates.create_double_neutron_capture(lib, reactant, product)[source]#
A helper function that will return a pair of
ApproximateRate
objects for the A(n,g)X(n,g)B -> A(nn,g)B approximation- Parameters:
- Return type: