Module to enforce constraints on interpolated quantities.
Constraints are split up into 3 types:
Astrophysical laws that must hold
Inequalities between values interpolated upon which must hold
Sums of values interpolated upon which must satisfy some inequality
For each type of constraint, different parameter dictionaries are required.
For type 1 constraints a dictionary with the following fields is required:
type - the type of constraint name - the name of the constraint dependent - the field for which the constraint must be calculated independent - the field names which are used to compute the dependent function - a function that computes the dependent from the independent
For type 2 constraints a dictionary with the following fields is required:
type - the type of constraint name - the name of the constraint fields - a multi dimensional array containing the field names in the
desired descending order (if usage with default enforcer is wanted)
- log - a boolean denoting whether or not the largest (first) field in
each constraint list is in log scale (by default false)
- function - a function that enforces the desired constraint (by default
inequality is corrected)
For type 3 constraints a dictionary with the following fields is required:
type - the type of constraint name - the name of the constraint sum - an array of fields whose sum needs to satisfy some inequality constraint - either a real number or fieldname that the sum needs to be
constrained by
- posydon.interpolation.constraints.Lnuc_func(log_LH, log_LHe, log_LZ)[source]
Total nuclear luminosity should be the sum of H, He and the rest.
- posydon.interpolation.constraints.boltzman_constraint_func(log_L, log_R)[source]
Boltzmann law constraint.
- posydon.interpolation.constraints.check_order_of_constraints()[source]
Report possible issues with the order of application of constraints.
TODO: this needs to be updated for the new types of constraints.
- posydon.interpolation.constraints.correct_inequality(fv_dict, key_sets, star, log=False)[source]
Apply an “unequality constraint” (type 2) if needed.
- Parameters
fv_dict (dict) – The final values dictionary.
key_sets (list of lists) – List of collections of keys connected with >= inequalities (descending order). E.g., if one constraint is a >= b >= c, then key_sets is [[a, b, c], …].
star (int) – For which star (1 or 2), the constraint will be applied. E.g., star_{}_mass will be either star_1_mass or star_2_mass.
log (bool) – If True, then the largest parameter (first key), is given in log10 scale, while all the rest are in linear scale.
- Returns
The sanitized version of fv_dict.
- Return type
- posydon.interpolation.constraints.correct_sum(fv_dict, sum_keys, constraint)[source]
Normalize quantities should their sum does not have the expected value.
- Parameters
- Returns
The sanitized version of the final values dictionary.
- Return type
- posydon.interpolation.constraints.find_constraints_to_apply(out_keys)[source]
Find out which constraints can be applied.
Find out which constraints can be applied based on the out_keys specified by the user. This function assumes that the keys for star 1 have a corresponding key in star 2 when applicable.
- Parameters
out_keys (list of strings) – The keys specified in the IFInterpolator
- Returns
A list of constraints that can and will be applied
- Return type
list of dicts
- posydon.interpolation.constraints.get_thickness_n_radius(fv_dict, constraint, keys)[source]
Corrects thickness and radius constraint violation of one is present.
- posydon.interpolation.constraints.kepler_3rd_law_func(period_days, mass1, mass2)[source]
Kepler’s 3rd law constraint.
- posydon.interpolation.constraints.lg_system_mdot_func(lg_system_mdot, lg_mtransfer_rate)[source]
System mdot must be less than the total mass-transfer rate.
- posydon.interpolation.constraints.sanitize_interpolated_quantities(fvalues, constraints, verbose=False)[source]
Apply constraints in final values returned from the IF interpolator.
- Parameters
fvalues (dict) – Dictionary containing the final values returned from the initial-final interpolator evaluation method.
constraints (list of dicts) – A list of constraints that are to be applied. Can be computed using the find_constraints_to_apply function
verbose (bool) – If True, report the actions.
- Returns
The dictionary of sanitized final values.
- Return type