import ctypes import tempfile import os from binaryc_python_utils.custom_logging_functions import ( autogen_C_logging_code, binary_c_log_code, compile_shared_lib, temp_custom_logging_dir, create_and_load_logging_function, ) import binary_c # generate logging lines logging_line = autogen_C_logging_code( { "MY_STELLAR_DATA": ["model.time", "star[0].mass"], "my_sss2": ["model.time", "star[1].mass"], } ) # Generate code around logging lines custom_logging_code = binary_c_log_code(logging_line) # Generate library and get memaddr func_memaddr = create_and_load_logging_function(custom_logging_code) # m1 = 15.0 # Msun m2 = 14.0 # Msun separation = 0 # 0 = ignored, use period orbital_period = 4530.0 # days eccentricity = 0.0 metallicity = 0.02 max_evolution_time = 15000 argstring = "binary_c M_1 {0:g} M_2 {1:g} separation {2:g} orbital_period {3:g} eccentricity {4:g} metallicity {5:g} max_evolution_time {6:g}".format( m1, m2, separation, orbital_period, eccentricity, metallicity, max_evolution_time ) output = binary_c.run_binary_custom_logging(argstring, func_memaddr) print(output)