diff --git a/src/amuse/community/petar/Makefile b/src/amuse/community/petar/Makefile index 44445b8d3c..ce9e666bda 100644 --- a/src/amuse/community/petar/Makefile +++ b/src/amuse/community/petar/Makefile @@ -26,6 +26,7 @@ CXXFLAGS += -D MPICH_IGNORE_CXX_SEEKC CXXFLAGS += -D SOFT_PERT -D AR_TTL -D AR_SLOWDOWN_TREE -D AR_SLOWDOWN_TIMESCALE -D CLUSTER_VELOCITY CXXFLAGS += -D USE_QUAD CXXFLAGS += -D STELLAR_EVOLUTION +CXXFLAGS += -D ADJUST_GROUP_PRINT CXXFLAGS += -D PROFILE CXXFLAGS += -D HARD_CHECK_ENERGY diff --git a/src/amuse/community/petar/interface.cc b/src/amuse/community/petar/interface.cc index 2c1ed6796a..cada513a17 100644 --- a/src/amuse/community/petar/interface.cc +++ b/src/amuse/community/petar/interface.cc @@ -49,7 +49,7 @@ extern "C" { // set print flag to rank 0 ptr->input_parameters.print_flag = (ptr->my_rank==0) ? true: false; // set writing flag to false - ptr->input_parameters.write_style.value = 0; + ptr->input_parameters.write_style.value = 3; // default input int flag= ptr->readParameters(argc,argv); @@ -106,6 +106,7 @@ extern "C" { ptr->input_parameters.update_changeover_flag = true; ptr->input_parameters.update_rsearch_flag = true; ptr->initialParameters(); + ptr->hard_manager.h4_manager.adjust_group_write_flag = true; ptr->initial_step_flag = false; // set stopping condtions support @@ -389,6 +390,15 @@ extern "C" { return 0; } + int get_binary_companion(int index_of_the_particle, int * binary_companion){ + reconstruct_particle_list(); + int index = 1 + ptr->getParticleAdrFromID(index_of_the_particle); + FPSoft* p = &(ptr->system_soft[index]); + //*binary_companion = ptr->getParticleIDFromAdr(p->getBinaryPairID()); + *binary_companion = p->getBinaryPairID() - 1; + return 0; + } + int get_position(int index_of_the_particle, double * x, double * y, double * z) { reconstruct_particle_list(); @@ -737,6 +747,7 @@ extern "C" { if (!ptr->read_data_flag) return -1; ptr->input_parameters.n_glb.value = ptr->stat.n_real_glb; ptr->initialParameters(); + ptr->hard_manager.h4_manager.adjust_group_write_flag = true; ptr->initialStep(); ptr->reconstructIdAdrMap(); particle_list_change_flag = false; diff --git a/src/amuse/community/petar/interface.h b/src/amuse/community/petar/interface.h index d7e8890e04..95714d220c 100644 --- a/src/amuse/community/petar/interface.h +++ b/src/amuse/community/petar/interface.h @@ -31,6 +31,8 @@ int get_radius(int index_of_the_particle, double * radius); int set_radius(int index_of_the_particle, double radius); +int get_binary_companion(int index_of_the_particle, int * binary_companion); + int get_position(int index_of_the_particle, double * x, double * y, double * z); int set_position(int index_of_the_particle, double x, double y, double z); diff --git a/src/amuse/community/petar/interface.py b/src/amuse/community/petar/interface.py index 977cb7e3cd..6a71b7fe20 100644 --- a/src/amuse/community/petar/interface.py +++ b/src/amuse/community/petar/interface.py @@ -1,4 +1,9 @@ -from amuse.rfi.core import legacy_function, LegacyFunctionSpecification +""" +Interface for PeTar +""" +from amuse.rfi.core import ( + legacy_function, LegacyFunctionSpecification, remote_function +) from amuse.community import ( CodeInterface, LiteratureReferencesMixIn, @@ -83,6 +88,13 @@ def set_theta(): """ return function + @remote_function(can_handle_array=True) + def get_binary_companion(index_of_the_particle='i'): + """ + Returns the binary companion of a particle, or -1 if no such companion exists + """ + returns (binary_companion='i') + #@legacy_function #def get_gravitational_constant(): # """ @@ -573,6 +585,17 @@ def define_methods(self, handler): ) ) + handler.add_method( + "get_binary_companion", + ( + handler.NO_UNIT, + ), + ( + handler.NO_UNIT, + handler.ERROR_CODE, + ) + ) + handler.add_method( "set_tree_step", ( @@ -614,6 +637,7 @@ def define_methods(self, handler): def define_particle_sets(self, handler): GravitationalDynamics.define_particle_sets(self, handler) self.stopping_conditions.define_particle_set(handler) + handler.add_getter('particles', 'get_binary_companion') PetarInterface = petarInterface