import binary_c_python_api from binarycpython.utils.custom_logging_functions import ( autogen_C_logging_code, binary_c_log_code, create_and_load_logging_function, ) from binarycpython.utils.grid import Population ################################################# # File containing examples for the custom logging # I'll put several logging snippets for different purposes in this file # ################################################# # no logging set. pop = Population() pop.set( M_1=10, M_2=10, separation=0, orbital_period=4530, eccentricity=0, metallicity=0.02, max_evolution_time=15000, ) out = pop.evolve_single() print(out) ################################################# # Example logging snippet for logging pop.set( C_logging_code=""" if(stardata->star[0].stellar_type>=MS) { if (stardata->model.time < stardata->model.max_evolution_time) { Printf("EXAMPLE_ABOVE_MS %30.12e %g %g %g %g %d %d\\n", // stardata->model.time, // 1 stardata->star[0].mass, //2 stardata->previous_stardata->star[0].mass, //3 stardata->star[0].radius, //4 stardata->previous_stardata->star[0].radius, //5 stardata->star[0].stellar_type, //6 stardata->previous_stardata->star[0].stellar_type //7 ); }; /* Kill the simulation to save time */ //stardata->model.max_evolution_time = stardata->model.time - stardata->model.dtm; }; """ ) out = pop.evolve_single() print(out) ################################################# # Example logging snippet for checking whether the system becomes a NS, and stop the evolution if so. pop.set( M_1=100, M_2=10, separation=0, orbital_period=400530, eccentricity=0, metallicity=0.002, max_evolution_time=15000, ) pop.set( C_logging_code=""" if(stardata->star[0].stellar_type>=NS) { if (stardata->model.time < stardata->model.max_evolution_time) { Printf("EXAMPLE_LOG_CO %30.12e %g %g %g %g %d %d\\n", // stardata->model.time, // 1 stardata->star[0].mass, //2 stardata->previous_stardata->star[0].mass, //3 stardata->star[0].radius, //4 stardata->previous_stardata->star[0].radius, //5 stardata->star[0].stellar_type, //6 stardata->previous_stardata->star[0].stellar_type //7 ); }; /* Kill the simulation to save time */ stardata->model.max_evolution_time = stardata->model.time - stardata->model.dtm; }; """ ) out = pop.evolve_single() # TODO: add function that shows a # TODO: add function for compact object mergers # TODO: add function