diff --git a/examples/notebook_api_functionality.ipynb b/examples/notebook_api_functionality.ipynb index 7ad47e326d31ebe767c2f230fc957f8968f20132..7275036c43afb9d7211ee20c930f82fced598f72 100644 --- a/examples/notebook_api_functionality.ipynb +++ b/examples/notebook_api_functionality.ipynb @@ -6,7 +6,7 @@ "metadata": {}, "source": [ "# Notebook API functionality\n", - "This notebook shows how to use the API functions that interface with binary_c. It usually is better to use \n", + "This notebook shows how to use the API functions that interface with binary_c. It usually is better to use wrapper functions that internally use these API functions, because most of the output here is very raw\n", "\n", "Binarycpython uses the Python-C extension framework to interface Python with C. The sourcecode for this is contained in `src/binary_c_python.c`, and the functions are available via `from binarycpython import _binary_c_bindings`.\n", "\n", @@ -815,552 +815,132 @@ "print(_binary_c_bindings.return_help_all())" ] }, + { + "cell_type": "markdown", + "id": "bfec32cf-7240-4a82-ac30-b3d99a018a28", + "metadata": {}, + "source": [ + "We can get all the parameter names and their default values with return_arglines(): (abridged output)" + ] + }, { "cell_type": "code", - "execution_count": null, - "id": "e4c47842-3304-449f-85ad-bf63359b55dd", + "execution_count": 20, + "id": "3d29ca9d-ac66-4f9e-81cf-2edd14a98b79", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "__ARG_BEGIN\n", + "metallicity = 0.02\n", + "effective_metallicity = -1\n", + "M_1 = 0\n" + ] + } + ], "source": [ - "- return_minimum_orbit_for_RLOF\n", - " - return_maximum_mass_ratio_for_RLOF\n", - " - return_arglines\n", - " " + "print('\\n'.join(_binary_c_bindings.return_arglines().splitlines()[:4]))" ] }, { "cell_type": "markdown", - "id": "bfec32cf-7240-4a82-ac30-b3d99a018a28", + "id": "e8b1c8b6-a878-43f4-bc36-1b20b3e66c6f", "metadata": {}, "source": [ - "We can get all the parameter names and their default values with return_arglines():" + "Lastly, we can ask binary_c to determine the minimum period or maximum mass for RLOF at the ZAMS: Both of them need an argstring as input" ] }, { "cell_type": "code", - "execution_count": 17, - "id": "3d29ca9d-ac66-4f9e-81cf-2edd14a98b79", + "execution_count": 24, + "id": "e517f561-09c6-419d-ba89-d9cb61e6ebab", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "__ARG_BEGIN\n", - "metallicity = 0.02\n", - "effective_metallicity = -1\n", - "M_1 = 0\n", - "M_2 = 0\n", - "M_3 = 0\n", - "M_4 = 0\n", - "vrot1 = 0\n", - "vrot2 = 0\n", - "vrot3 = 0\n", - "vrot4 = 0\n", - "Prot1 = 0\n", - "Prot2 = 0\n", - "Prot3 = 0\n", - "Prot4 = 0\n", - "inclination1 = 0\n", - "inclination2 = 0\n", - "inclination3 = 0\n", - "inclination4 = 0\n", - "B_1 = 0\n", - "B_2 = 0\n", - "B_3 = 0\n", - "B_4 = 0\n", - "B_inclination1 = 0\n", - "B_inclination2 = 0\n", - "B_inclination3 = 0\n", - "B_inclination4 = 0\n", - "separation = 0\n", - "separation_triple = 0\n", - "separation_quadruple = 0\n", - "orbital_period = 0\n", - "orbital_period_triple = 0\n", - "orbital_period_quadruple = 0\n", - "eccentricity = 0\n", - "eccentricity_triple = 0\n", - "eccentricity_quadruple = 0\n", - "incliniation = 0\n", - "incliniation_triple = 0\n", - "incliniation_quadruple = 0\n", - "orbital_phase = 0\n", - "orbital_phase_triple = 0\n", - "orbital_phase_quadruple = 0\n", - "argument_of_periastron = 0\n", - "argument_of_periastron_triple = 0\n", - "argument_of_periastron_quadruple = 0\n", - "stellar_type_1 = 0\n", - "stellar_type_2 = 0\n", - "stellar_type_3 = 0\n", - "stellar_type_4 = 0\n", - "max_stellar_type_1 = 16\n", - "max_stellar_type_2 = 16\n", - "max_stellar_type_3 = 16\n", - "max_stellar_type_4 = 16\n", - "probability = 1\n", - "phasevol = NULL\n", - "stellar_structure_algorithm = 0\n", - "solver = 0\n", - "max_evolution_time = 15000\n", - "max_model_number = 0\n", - "monte_carlo_kicks = True\n", - "disable_debug = False\n", - "timestep_logging = False\n", - "rejects_in_log = False\n", - "vandenHeuvel_logging = False\n", - "disc_timestep_factor = 0.01\n", - "white_dwarf_cooling_model = 0\n", - "white_dwarf_radius_model = 0\n", - "cbdisc_mass_loss_inner_viscous_accretion_method = 0\n", - "cbdisc_inner_edge_stripping = True\n", - "cbdisc_end_evolution_after_disc = False\n", - "cbdisc_no_wind_if_cbdisc = False\n", - "cbdisc_outer_edge_stripping = True\n", - "disc_n_monte_carlo_guesses = 0\n", - "disc_log = 0\n", - "disc_log2d = 0\n", - "disc_log_dt = 0\n", - "disc_log_directory = /tmp/\n", - "post_ce_adaptive_menv = False\n", - "post_ce_objects_have_envelopes = True\n", - "PN_comenv_transition_time = 100\n", - "minimum_time_between_PNe = 0.1\n", - "PN_Hall_fading_time_algorithm = 0\n", - "PPN_envelope_mass = 0.01\n", - "cbdisc_eccentricity_pumping_method = 1\n", - "cbdisc_viscous_photoevaporative_coupling = 1\n", - "cbdisc_inner_edge_stripping_timescale = 1\n", - "cbdisc_outer_edge_stripping_timescale = 1\n", - "cbdisc_viscous_L2_coupling = 1\n", - "gravitational_radiation_model = 0\n", - "nova_irradiation_multiplier = 0\n", - "gravitational_radiation_modulator_J = 1\n", - "gravitational_radiation_modulator_e = 1\n", - "nova_faml_multiplier = 0\n", - "RLOF_angular_momentum_transfer_model = 0\n", - "post_SN_orbit_method = 1\n", - "evolution_splitting = False\n", - "disable_events = False\n", - "evolution_splitting_sn_eccentricity_threshold = 0.01\n", - "evolution_splitting_sn_n = 10\n", - "evolution_splitting_maxdepth = 2\n", - "random_seed = 0\n", - "random_systems_seed = 0\n", - "random_skip = 0\n", - "idum = 0\n", - "repeat = 1\n", - "random_systems = 0\n", - "equation_of_state_algorithm = NULL\n", - "opacity_algorithm = NULL\n", - "wind_mass_loss = 3\n", - "multiplicity = 0\n", - "gbwind = 0\n", - "mattsson_Orich_tpagbwind = NULL\n", - "magnetic_braking_factor = 1\n", - "magnetic_braking_gamma = 3\n", - "magnetic_braking_algorithm = 0\n", - "helium_flash_mass_loss = 0\n", - "gb_reimers_eta = 0.4\n", - "gbwindfac = 1\n", - "tpagbwindfac = 1\n", - "eagbwindfac = 1\n", - "nieuwenhuijzen_windfac = 1\n", - "tpagbwind = 0\n", - "eagbwind = 0\n", - "wind_gas_to_dust_ratio = 200\n", - "vwind_multiplier = 1\n", - "vwind_beta = 0.125\n", - "superwind_mira_switchon = 500\n", - "vw93_mira_shift = 0\n", - "vw93_multiplier = 1\n", - "tpagb_reimers_eta = 1\n", - "artificial_mass_accretion_rate%d = \n", - "artificial_angular_momentum_accretion_rate%d = \n", - "artificial_orbital_angular_momentum_accretion_rate = 0\n", - "artificial_accretion_start_time = -1\n", - "artificial_accretion_end_time = -1\n", - "wr_wind = 0\n", - "wr_wind_fac = 1\n", - "wrwindfac = 1\n", - "accretion_limit_eddington_steady_multiplier = 1\n", - "accretion_limit_eddington_LMMS_multiplier = 1\n", - "accretion_limit_eddington_WD_to_remnant_multiplier = -1\n", - "accretion_limit_thermal_multiplier = 1\n", - "accretion_limit_dynamical_multiplier = 1\n", - "donor_limit_envelope_multiplier = 0\n", - "donor_limit_thermal_multiplier = 1\n", - "donor_limit_dynamical_multiplier = 1\n", - "Bondi_Hoyle_accretion_factor = 1.5\n", - "BH_prescription = 0\n", - "david_logging_function = 0\n", - "PPISN_prescription = 1\n", - "sn_kick_distribution_II = 1\n", - "sn_kick_distribution_ECAP = 0\n", - "sn_kick_distribution_NS_NS = 0\n", - "sn_kick_distribution_IBC = 1\n", - "sn_kick_distribution_GRB_COLLAPSAR = 0\n", - "sn_kick_distribution_TZ = 0\n", - "sn_kick_distribution_AIC_BH = 0\n", - "sn_kick_distribution_BH_BH = 0\n", - "sn_kick_distribution_BH_NS = 0\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD = 0\n", - "sn_kick_distribution_IA_Hybrid_HeCOWD_subluminous = 0\n", - "sn_kick_distribution_PPISN = 1\n", - "sn_kick_distribution_PISN = 0\n", - "sn_kick_distribution_PHDIS = 0\n", - "sn_kick_dispersion_II = 190\n", - "sn_kick_dispersion_ECAP = 0\n", - "sn_kick_dispersion_NS_NS = 0\n", - "sn_kick_dispersion_IBC = 190\n", - "sn_kick_dispersion_GRB_COLLAPSAR = 0\n", - "sn_kick_dispersion_TZ = 0\n", - "sn_kick_dispersion_AIC_BH = 0\n", - "sn_kick_dispersion_BH_BH = 0\n", - "sn_kick_dispersion_BH_NS = 0\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD = 0\n", - "sn_kick_dispersion_IA_Hybrid_HeCOWD_subluminous = 0\n", - "sn_kick_dispersion_PPISN = 190\n", - "sn_kick_dispersion_PISN = 0\n", - "sn_kick_dispersion_PHDIS = 0\n", - "sn_kick_companion_IA_He = 0\n", - "sn_kick_companion_IA_ELD = 0\n", - "sn_kick_companion_IA_CHAND = 0\n", - "sn_kick_companion_AIC = 0\n", - "sn_kick_companion_ECAP = 0\n", - "sn_kick_companion_IA_He_Coal = 0\n", - "sn_kick_companion_IA_CHAND_Coal = 0\n", - "sn_kick_companion_NS_NS = 0\n", - "sn_kick_companion_GRB_COLLAPSAR = 0\n", - "sn_kick_companion_HeStarIa = 0\n", - "sn_kick_companion_IBC = 0\n", - "sn_kick_companion_II = 0\n", - "sn_kick_companion_IIa = 0\n", - "sn_kick_companion_WDKICK = 0\n", - "sn_kick_companion_TZ = 0\n", - "sn_kick_companion_AIC_BH = 0\n", - "sn_kick_companion_BH_BH = 0\n", - "sn_kick_companion_BH_NS = 0\n", - "sn_kick_companion_IA_Hybrid_HeCOWD = 0\n", - "sn_kick_companion_IA_Hybrid_HeCOWD_subluminous = 0\n", - "sn_kick_companion_PPISN = 0\n", - "sn_kick_companion_PISN = 0\n", - "sn_kick_companion_PHDIS = 0\n", - "wd_sigma = 0\n", - "wd_kick_direction = 0\n", - "wd_kick_when = 0\n", - "wd_kick_pulse_number = 0\n", - "minimum_helium_ignition_core_mass = 0\n", - "minimum_CO_core_mass_for_carbon_ignition = 1.08\n", - "minimum_CO_core_mass_for_neon_ignition = 1.42\n", - "minimum_mcbagb_for_nondegenerate_carbon_ignition = 2.25\n", - "maximum_mcbagb_for_degenerate_carbon_ignition = 1.6\n", - "max_neutron_star_mass = 2.2\n", - "chandrasekhar_mass = 1.38\n", - "delta_mcmin = NULL\n", - "lambda_min = NULL\n", - "lambda_multiplier = NULL\n", - "minimum_envelope_mass_for_third_dredgeup = NULL\n", - "cf_amanda_log = NULL\n", - "float_overflow_checks = 0\n", - "save_pre_events_stardata = False\n", - "disable_end_logging = False\n", - "mass_of_pmz = NULL\n", - "c13_eff = NULL\n", - "mc13_pocket_multiplier = NULL\n", - "tides_convective_damping = 0\n", - "E2_prescription = 0\n", - "dtfac = 1\n", - "hbbtfac = NULL\n", - "tidal_strength_factor = 1\n", - "hachisu_qcrit = 1.15\n", - "hachisu_disk_wind = False\n", - "mass_accretion_for_eld = 0.15\n", - "WDWD_merger_algorithm = 0\n", - "type_Ia_MCh_supernova_algorithm = NULL\n", - "Seitenzahl2013_model = NULL\n", - "type_Ia_sub_MCh_supernova_algorithm = NULL\n", - "max_HeWD_mass = 0.7\n", - "merger_mass_loss_fraction = 0\n", - "merger_angular_momentum_factor = 1\n", - "wind_angular_momentum_loss = 0\n", - "wind_djorb_fac = 1\n", - "lw = 1\n", - "VW93_EAGB_wind_speed = False\n", - "VW93_TPAGB_wind_speed = False\n", - "ensemble = False\n", - "ensemble_filters_off = False\n", - "ensemble_filter_%d = \n", - "ensemble_legacy_ensemble = False\n", - "legacy_yields = NULL\n", - "ensemble_defer = False\n", - "ensemble_dt = 1\n", - "ensemble_logdt = 0.1\n", - "ensemble_startlogtime = 0.1\n", - "ensemble_logtimes = False\n", - "postagb_legacy_logging = False\n", - "disc_legacy_logging = False\n", - "wind_multiplier_%d = \n", - "wind_type_multiplier_%d = \n", - "reverse_time = NULL\n", - "start_time = 0\n", - "EMP_logg_maximum = NULL\n", - "EMP_minimum_age = NULL\n", - "EMP_feh_maximum = NULL\n", - "CEMP_cfe_minimum = NULL\n", - "NEMP_cfe_minimum = NULL\n", - "thick_disc_start_age = NULL\n", - "thick_disc_end_age = NULL\n", - "thick_disc_logg_min = NULL\n", - "thick_disc_logg_max = NULL\n", - "escape_velocity = NULL\n", - "escape_fraction = NULL\n", - "pre_main_sequence = False\n", - "pre_main_sequence_fit_lobes = False\n", - "use_periastron_Roche_radius = False\n", - "qcrit_LMMS = 0.6944\n", - "qcrit_MS = 1.6\n", - "qcrit_HG = 4\n", - "qcrit_GB = -1\n", - "qcrit_CHeB = 3\n", - "qcrit_EAGB = -1\n", - "qcrit_TPAGB = -1\n", - "qcrit_HeMS = 3\n", - "qcrit_HeHG = 4\n", - "qcrit_HeGB = 0.78125\n", - "qcrit_HeWD = 3\n", - "qcrit_COWD = 3\n", - "qcrit_ONeWD = 3\n", - "qcrit_NS = 3\n", - "qcrit_BH = 3\n", - "qcrit_degenerate_LMMS = 1\n", - "qcrit_degenerate_MS = 1\n", - "qcrit_degenerate_HG = 4.7619\n", - "qcrit_degenerate_GB = 1.15\n", - "qcrit_degenerate_CHeB = 3\n", - "qcrit_degenerate_EAGB = 1.15\n", - "qcrit_degenerate_TPAGB = 1.15\n", - "qcrit_degenerate_HeMS = 3\n", - "qcrit_degenerate_HeHG = 4.7619\n", - "qcrit_degenerate_HeGB = 1.15\n", - "qcrit_degenerate_HeWD = 0.625\n", - "qcrit_degenerate_COWD = 0.625\n", - "qcrit_degenerate_ONeWD = 0.625\n", - "qcrit_degenerate_NS = 0.625\n", - "qcrit_degenerate_BH = 0.625\n", - "mass_for_Hestar_Ia_upper = 0\n", - "mass_for_Hestar_Ia_lower = 0\n", - "alphaCB = NULL\n", - "minimum_donor_menv_for_comenv = 0\n", - "comenv_prescription = 0\n", - "comenv_prescription%d = \n", - "comenv_ejection_spin_method = 0\n", - "comenv_merger_spin_method = 0\n", - "comenv_ms_accretion_mass = NULL\n", - "comenv_ms_accretion_fraction = NULL\n", - "comenv_ns_accretion_mass = NULL\n", - "comenv_ns_accretion_fraction = NULL\n", - "alpha_ce = 1\n", - "alpha_ce%d = \n", - "lambda_ce = 0.5\n", - "lambda_ce%d = \n", - "comenv_splitmass = NULL\n", - "nelemans_recalc_eccentricity = False\n", - "comenv_post_eccentricity = 1e-05\n", - "nelemans_gamma = 1.75\n", - "nelemans_minq = 0.2\n", - "nelemans_max_frac_j_change = 1\n", - "nelemans_n_comenvs = 1\n", - "lambda_ionisation = 0.5\n", - "lambda_ionisation%d = \n", - "lambda_enthalpy = 0\n", - "lambda_enthalpy%d = \n", - "cbdisc_albedo = 0\n", - "cbdisc_gamma = 1.4\n", - "cbdisc_alpha = 0.001\n", - "cbdisc_kappa = 0.01\n", - "cbdisc_minimum_evaporation_timescale = 1\n", - "cbdisc_torquef = 0.001\n", - "cbdisc_max_lifetime = 1e+06\n", - "cbdisc_init_dM = 0.1\n", - "cbdisc_init_dJdM = 0.5\n", - "cbdisc_mass_loss_constant_rate = 0\n", - "cbdisc_mass_loss_FUV_multiplier = 1\n", - "cbdisc_mass_loss_Xray_multiplier = 1\n", - "cbdisc_mass_loss_ISM_ram_pressure_multiplier = 1\n", - "cbdisc_mass_loss_ISM_pressure = 3000\n", - "cbdisc_mass_loss_inner_viscous_multiplier = 1\n", - "cbdisc_mass_loss_inner_viscous_angular_momentum_multiplier = 1\n", - "cbdisc_resonance_multiplier = 1\n", - "cbdisc_resonance_damping = True\n", - "cbdisc_fail_ring_inside_separation = False\n", - "cbdisc_mass_loss_inner_L2_cross_multiplier = 1\n", - "cbdisc_minimum_luminosity = 0\n", - "cbdisc_minimum_mass = 1e-06\n", - "cbdisc_minimum_fRing = 0.2\n", - "comenv_disc_angmom_fraction = 0\n", - "comenv_disc_mass_fraction = 0\n", - "wind_disc_angmom_fraction = 0\n", - "wind_disc_mass_fraction = 0\n", - "WRLOF_method = 0\n", - "minimum_timestep = 1e-06\n", - "timestep_solver_factor = 1\n", - "RLOF_mdot_factor = 1\n", - "RLOF_f = NULL\n", - "minimum_separation_for_instant_RLOF = False\n", - "minimum_orbital_period_for_instant_RLOF = False\n", - "maximum_mass_ratio_for_instant_RLOF = False\n", - "RLOF_method = 0\n", - "small_envelope_method = 0\n", - "RLOF_interpolation_method = 0\n", - "timestep_modulator = 1\n", - "timestep_multiplier%d = \n", - "maximum_timestep = 1e+20\n", - "zoomfac_multiplier_decrease = 0.5\n", - "zoomfac_multiplier_increase = 1.2\n", - "maximum_timestep_factor = 0\n", - "maximum_nuclear_burning_timestep = 1e+20\n", - "nova_retention_method = 0\n", - "nova_retention_fraction = 0.001\n", - "beta_reverse_nova = 0\n", - "WD_accretion_rate_novae_upper_limit_hydrogen_donor = -1\n", - "WD_accretion_rate_novae_upper_limit_helium_donor = -1\n", - "WD_accretion_rate_novae_upper_limit_other_donor = -1\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_hydrogen_donor = -1\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_helium_donor = -1\n", - "WD_accretion_rate_new_giant_envelope_lower_limit_other_donor = -1\n", - "CRAP_parameter = 0\n", - "colour_log = False\n", - "log_filename = /tmp/c_log.dat\n", - "stopfile = empty_string\n", - "MINT_metallicity = NULL\n", - "MINT_dir = NULL\n", - "MINT_data_cleanup = NULL\n", - "MINT_MS_rejuvenation = NULL\n", - "MINT_remesh = NULL\n", - "MINT_use_ZAMS_profiles = NULL\n", - "MINT_disable_grid_load_warnings = NULL\n", - "MINT_Kippenhahn = NULL\n", - "MINT_Kippenhahn_stellar_type = NULL\n", - "MINT_Kippenhahn_companion_stellar_type = NULL\n", - "MINT_nuclear_burning = NULL\n", - "MINT_minimum_shell_mass = NULL\n", - "MINT_maximum_shell_mass = NULL\n", - "stardata_dump_filename = empty_string\n", - "stardata_load_filename = empty_string\n", - "api_log_filename_prefix = /dev/null\n", - "hrdiag_output = NULL\n", - "internal_buffering = 2\n", - "individual_novae = False\n", - "nova_timestep_accelerator_num = 100\n", - "nova_timestep_accelerator_index = 0.5\n", - "nova_timestep_accelerator_max = -1\n", - "eccentric_RLOF_model = 0\n", - "force_circularization_on_RLOF = True\n", - "nonconservative_angmom_gamma = -1\n", - "max_stellar_angmom_change = 0.05\n", - "comenv_ms_accretion_mass = NULL\n", - "third_dup = True\n", - "third_dup_multiplier = NULL\n", - "NeNaMgAl = NULL\n", - "nucsyn_network%d = NULL\n", - "nucsyn_network_error%d = NULL\n", - "nucreacmult%d = NULL\n", - "nucsyn_metallicity = NULL\n", - "nucsyn_solver = NULL\n", - "initial_abundance_mix = NULL\n", - "init_abund = NULL\n", - "init_abund_mult = NULL\n", - "init_abund_dex = NULL\n", - "init_abunds_only = NULL\n", - "initial_abunds_only = NULL\n", - "no_thermohaline_mixing = NULL\n", - "wtts_log = False\n", - "lithium_GB_post_Heflash = NULL\n", - "lithium_GB_post_1DUP = NULL\n", - "lithium_hbb_multiplier = NULL\n", - "angelou_lithium_decay_function = NULL\n", - "angelou_lithium_LMMS_time = NULL\n", - "angelou_lithium_MS_time = NULL\n", - "angelou_lithium_HG_time = NULL\n", - "angelou_lithium_GB_time = NULL\n", - "angelou_lithium_CHeB_time = NULL\n", - "angelou_lithium_EAGB_time = NULL\n", - "angelou_lithium_TPAGB_time = NULL\n", - "angelou_lithium_LMMS_decay_time = NULL\n", - "angelou_lithium_MS_decay_time = NULL\n", - "angelou_lithium_HG_decay_time = NULL\n", - "angelou_lithium_GB_decay_time = NULL\n", - "angelou_lithium_CHeB_decay_time = NULL\n", - "angelou_lithium_EAGB_decay_time = NULL\n", - "angelou_lithium_TPAGB_decay_time = NULL\n", - "angelou_lithium_LMMS_massfrac = NULL\n", - "angelou_lithium_MS_massfrac = NULL\n", - "angelou_lithium_HG_massfrac = NULL\n", - "angelou_lithium_GB_massfrac = NULL\n", - "angelou_lithium_CHeB_massfrac = NULL\n", - "angelou_lithium_EAGB_massfrac = NULL\n", - "angelou_lithium_TPAGB_massfrac = NULL\n", - "angelou_lithium_vrot_trigger = NULL\n", - "angelou_lithium_vrotfrac_trigger = NULL\n", - "gaia_Teff_binwidth = NULL\n", - "gaia_L_binwidth = NULL\n", - "fabian_imf_log_time = NULL\n", - "fabian_imf_log_timestep = NULL\n", - "gaia_colour_transform_method = 4\n", - "rotationally_enhanced_mass_loss = 0\n", - "AGB_core_algorithm = 1\n", - "AGB_radius_algorithm = 1\n", - "AGB_luminosity_algorithm = 1\n", - "AGB_3dup_algorithm = 1\n", - "overspin_algorithm = 0\n", - "rotationally_enhanced_exponent = 1\n", - "warmup_cpu = NULL\n", - "help = NULL\n", - "argopts = NULL\n", - "help_all = NULL\n", - "list_args = NULL\n", - "version = NULL\n", - "dumpversion = NULL\n", - "version_only = NULL\n", - "batchmode = 3\n", - "speedtests = False\n", - "use_fixed_timestep_%d = \n", - "task%d = \n", - "orbiting_object = NULL\n", - "orbiting_objects_log = False\n", - "orbiting_objects_log = False\n", - "orbiting_objects_wind_accretion_multiplier = 1.5\n", - "orbiting_objects_close_pc_threshold = 1\n", - "orbiting_objects_tides_multiplier = 1\n", - "evaporate_escaped_orbiting_objects = False\n", - "RLOF_transition_objects_escape = False\n", - "PN_resolve = False\n", - "PN_resolve_minimum_luminosity = 31.62\n", - "PN_resolve_maximum_envelope_mass = 0.1\n", - "PN_resolve_minimum_effective_temperature = 12500\n", - "PN_fast_wind = False\n", - "PN_fast_wind_dm_GB = 0.01\n", - "PN_fast_wind_mdot_GB = 1e-06\n", - "PN_fast_wind_dm_AGB = 0.001\n", - "PN_fast_wind_mdot_AGB = 1e-06\n", - "HeWD_HeWD_ignition_mass = 0.3\n", - "wind_Nieuwenhuijzen_luminosity_lower_limit = 4000\n", - "wind_LBV_luminosity_lower_limit = 600000\n", - "__ARG_END\n", + "<capsule object \"STORE\" at 0x7f163859d6c0>\n" + ] + }, + { + "ename": "TypeError", + "evalue": "return_minimum_orbit_for_RLOF() takes no keyword arguments", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m<ipython-input-24-949a85689f9b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;31m#\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 17\u001b[0;31m \u001b[0moutput\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_binary_c_bindings\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreturn_minimum_orbit_for_RLOF\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margstring\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstore_memaddr\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mstore_memaddr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 18\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0moutput\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: return_minimum_orbit_for_RLOF() takes no keyword arguments" + ] + } + ], + "source": [ + "\n", + "\n", + "\n", + "# allocating store memory\n", + "store_memaddr = _binary_c_bindings.return_store_memaddr()\n", + "print(store_memaddr)\n", + "\n", + "# Here we set up the argument string that is passed to the bindings\n", + "argstring = \"\"\"\n", + "binary_c M_1 {M_1} orbital_period {orbital_period} eccentricity {eccentricity} metallicity {metallicity} max_evolution_time {max_evolution_time}\n", + "\"\"\".format(\n", + " M_1=10,\n", + " orbital_period=4500,\n", + " eccentricity=0.0,\n", + " metallicity=0.02,\n", + " max_evolution_time=15000,\n", + ").strip()\n", + "\n", + "#\n", + "output = _binary_c_bindings.return_minimum_orbit_for_RLOF(argstring, store_memaddr=store_memaddr)\n", + "print(output)\n", + "\n", + "# Freeing store\n", + "_binary_c_bindings.free_store_memaddr(store_memaddr)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "id": "7da75a95-8831-4346-a584-e042ced75249", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "MAXIMUM MASS RATIO 0.0141\n", "\n" ] } ], "source": [ - "print(_binary_c_bindings.return_arglines())" + "# Here we set up the argument string that is passed to the bindings\n", + "argstring = \"\"\"\n", + "binary_c M_1 {M_1} orbital_period {orbital_period} eccentricity {eccentricity} metallicity {metallicity} max_evolution_time {max_evolution_time}\n", + "\"\"\".format(\n", + " M_1=5,\n", + " M_2=1,\n", + " orbital_period=0.0001,\n", + " eccentricity=0.0,\n", + " metallicity=0.02,\n", + " max_evolution_time=15000,\n", + ").strip()\n", + "\n", + "#\n", + "output = _binary_c_bindings.return_maximum_mass_ratio_for_RLOF(argstring)\n", + "print(output)" ] }, { "cell_type": "code", "execution_count": null, - "id": "90c1b0f7-4778-463c-b401-6d202a7e8a9a", + "id": "5fe52d8e-1721-4796-a856-002cf4525d96", "metadata": {}, "outputs": [], "source": [] diff --git a/src/binary_c_python.c b/src/binary_c_python.c index b0362fbdbb7914a6c66c8c869d6e28d8dfaf2dc6..d0156e6dab2e751168682f1db45e636370d2a9e9 100644 --- a/src/binary_c_python.c +++ b/src/binary_c_python.c @@ -110,7 +110,7 @@ static PyObject* python_return_arglines(PyObject *self, PyObject *args); static PyObject* python_return_help_info(PyObject *self, PyObject *args); static PyObject* python_return_help_all_info(PyObject *self, PyObject *args); static PyObject* python_return_version_info(PyObject *self, PyObject *args); -static PyObject* python_return_minimum_orbit_for_RLOF(PyObject *self, PyObject *args); +static PyObject* python_return_minimum_orbit_for_RLOF(PyObject *self, PyObject *args, PyObject *kwargs); static PyObject* python_return_maximum_mass_ratio_for_RLOF(PyObject *self, PyObject *args, PyObject *kwargs); // Other function headers @@ -132,7 +132,7 @@ static PyMethodDef module_methods[] = { {"return_help", python_return_help_info, METH_VARARGS, return_help_info_docstring}, {"return_help_all", python_return_help_all_info, METH_VARARGS, return_help_all_info_docstring}, {"return_version_info", python_return_version_info, METH_VARARGS, return_version_info_docstring}, - {"return_minimum_orbit_for_RLOF", python_return_minimum_orbit_for_RLOF, METH_VARARGS, return_minimum_orbit_for_RLOF_docstring}, + {"return_minimum_orbit_for_RLOF", (PyCFunction)python_return_minimum_orbit_for_RLOF, METH_VARARGS|METH_KEYWORDS, return_minimum_orbit_for_RLOF_docstring}, {"return_maximum_mass_ratio_for_RLOF", (PyCFunction)python_return_maximum_mass_ratio_for_RLOF, METH_VARARGS|METH_KEYWORDS, return_maximum_mass_ratio_for_RLOF_docstring}, // memory @@ -386,19 +386,33 @@ static PyObject* python_return_version_info(PyObject *self, PyObject *args) return return_string; } -static PyObject* python_return_minimum_orbit_for_RLOF(PyObject *self, PyObject *args) +static PyObject* python_return_minimum_orbit_for_RLOF(PyObject *self, PyObject *args, PyObject *kwargs) { /* set vars and default values for some */ char *argstring; - long int store_memaddr = -1; + PyObject * store_capsule = NULL; + + static char* keywords[] = {"argstring", "store_capsule", NULL}; - // By using the keywords argument it scans over the given set of kwargs, but if they are not given then the default value is used /* Parse the input tuple */ - if(!PyArg_ParseTuple(args, "sl", &argstring, &store_memaddr)) + // By using the keywords argument it scans over the given set of kwargs, but if they are not given then the default value is used + if(!PyArg_ParseTupleAndKeywords(args, kwargs, "s|O", keywords, &argstring, &store_capsule)) { return NULL; } + // Store + struct libbinary_c_store_t * store = NULL; + if (store_capsule != NULL) + { + if (PyCapsule_IsValid(store_capsule, "STORE")) + { + if (!(store = (struct libbinary_c_store_t *) PyCapsule_GetPointer(store_capsule, "STORE"))) + return NULL; + debug_printf("Unpacked store pointer %p from capsule\n", store_capsule); + } + } + // Setup buffers char * buffer; char * error_buffer;