Skip to content

Commit bd84576

Browse files
committed
cleanup tidymess interface.py
1 parent ad5130e commit bd84576

1 file changed

Lines changed: 71 additions & 54 deletions

File tree

src/amuse_tidymess/interface.py

Lines changed: 71 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
"""
2-
TIdal DYnamics of Multi-body ExtraSolar Systems Interface
3-
Code Author : Tjarda Boekholt & Alexandre Correia (MNRAS 2023, vol. 522, pp. 2885–2900)
4-
Interface Author : Elko Gerville-Reache
5-
6-
Date Created : Nov 25, 2025
7-
Last Updated : May 13, 2026
8-
"""
9-
10-
from amuse.community.interface.gd import GravitationalDynamics
11-
from amuse.community.interface.gd import GravitationalDynamicsInterface
12-
from amuse.community.interface.gd import GravityFieldInterface
13-
from amuse.community.interface.gd import GravityFieldCode
14-
from amuse.community.interface.stopping_conditions import StoppingConditions, StoppingConditionInterface
15-
from amuse.rfi.core import CodeInterface, legacy_function, LegacyFunctionSpecification
1+
from amuse.community.interface.gd import (
2+
GravitationalDynamics,
3+
GravitationalDynamicsInterface,
4+
GravityFieldInterface,
5+
GravityFieldCode
6+
)
7+
from amuse.community.interface.stopping_conditions import (
8+
StoppingConditions, StoppingConditionInterface
9+
)
10+
from amuse.rfi.core import (
11+
CodeInterface, legacy_function, LegacyFunctionSpecification
12+
)
1613
from amuse.support.literature import LiteratureReferencesMixIn
1714
from amuse.units import units as u, nbody_system
1815

@@ -1019,42 +1016,47 @@ def set_n_iter():
10191016
return function
10201017

10211018
@legacy_function
1022-
def set_collision_mode():
1023-
'''
1024-
'''
1019+
def get_collision_mode():
1020+
"""Get collision mode Tidymess parameter."""
10251021
function = LegacyFunctionSpecification()
10261022
function.addParameter(
10271023
'collision_mode',
10281024
dtype='int32',
1029-
direction=function.IN,
1030-
description='0=off, 1=flag, 2=exception, 3=replace'
1031-
)
1025+
direction=function.OUT,
1026+
description='0=off, 1=flag, 2=exception, 3=replace')
10321027
function.result_type = 'int32'
1033-
function.result_doc = ''''''
1028+
function.result_doc = """\
1029+
0 - OK
1030+
collision mode was retrieved
1031+
-1 - ERROR
1032+
Could not find collision mode
1033+
"""
10341034

10351035
return function
10361036

1037-
10381037
@legacy_function
1039-
def get_collision_mode():
1040-
'''
1041-
'''
1038+
def set_collision_mode():
1039+
"""Set collision mode Tidymess parameter."""
10421040
function = LegacyFunctionSpecification()
10431041
function.addParameter(
10441042
'collision_mode',
10451043
dtype='int32',
1046-
direction=function.OUT,
1047-
description='0=off, 1=flag, 2=exception, 3=replace')
1044+
direction=function.IN,
1045+
description='0=off, 1=flag, 2=exception, 3=replace'
1046+
)
10481047
function.result_type = 'int32'
1049-
function.result_doc = ''''''
1048+
function.result_doc = """\
1049+
0 - OK
1050+
collision mode was set
1051+
-1 - ERROR
1052+
Could not set collision mode
1053+
"""
10501054

10511055
return function
10521056

1053-
10541057
@legacy_function
10551058
def set_roche_mode():
1056-
'''
1057-
'''
1059+
"""Set roche mode."""
10581060
function = LegacyFunctionSpecification()
10591061
function.addParameter(
10601062
'roche_mode',
@@ -1063,15 +1065,18 @@ def set_roche_mode():
10631065
description='0=off, 1=flag, 2=exception'
10641066
)
10651067
function.result_type = 'int32'
1066-
function.result_doc = ''''''
1068+
function.result_doc = """\
1069+
0 - OK
1070+
Roche mode was set
1071+
-1 - ERROR
1072+
Could not set roche mode
1073+
"""
10671074

10681075
return function
10691076

1070-
10711077
@legacy_function
10721078
def get_roche_mode():
1073-
"""
1074-
"""
1079+
"""Get roche mode."""
10751080
function = LegacyFunctionSpecification()
10761081
function.addParameter(
10771082
'roche_mode',
@@ -1080,11 +1085,15 @@ def get_roche_mode():
10801085
description='0=off, 1=flag, 2=exception'
10811086
)
10821087
function.result_type = 'int32'
1083-
function.result_doc = ''''''
1088+
function.result_doc = """\
1089+
0 - OK
1090+
roche mode was retrieved
1091+
-1 - ERROR
1092+
Could not retrieve roche mode
1093+
"""
10841094

10851095
return function
10861096

1087-
10881097
@legacy_function
10891098
def set_breakup_mode():
10901099
"""
@@ -1104,7 +1113,6 @@ def set_breakup_mode():
11041113

11051114
return function
11061115

1107-
11081116
@legacy_function
11091117
def get_breakup_mode():
11101118
"""
@@ -1125,36 +1133,42 @@ def get_breakup_mode():
11251133
return function
11261134

11271135
@legacy_function
1128-
def set_initial_shape():
1129-
"""
1130-
Set Tidymess initial shape.
1131-
"""
1136+
def get_initial_shape():
1137+
"""Get Tidymess initial shape value."""
11321138
function = LegacyFunctionSpecification()
11331139
function.addParameter(
11341140
'initial_shape',
11351141
dtype='int32',
1136-
direction=function.IN,
1137-
description='0=default'
1142+
direction=function.OUT,
1143+
description='0=sphere, 1=equilibrium'
11381144
)
11391145
function.result_type = 'int32'
1140-
function.result_doc = """"""
1146+
function.result_doc = """\
1147+
0 - OK
1148+
Initial shape was retrieved
1149+
-1 - ERROR
1150+
Could not retrieve initial shape
1151+
"""
11411152

11421153
return function
11431154

11441155
@legacy_function
1145-
def get_initial_shape():
1146-
"""
1147-
Get Tidymess initial shape value.
1148-
"""
1156+
def set_initial_shape():
1157+
"""Set Tidymess initial shape."""
11491158
function = LegacyFunctionSpecification()
11501159
function.addParameter(
11511160
'initial_shape',
11521161
dtype='int32',
1153-
direction=function.OUT,
1154-
description=''
1162+
direction=function.IN,
1163+
description='0=sphere, 1=equilibrium'
11551164
)
11561165
function.result_type = 'int32'
1157-
function.result_doc = """"""
1166+
function.result_doc = """\
1167+
0 - OK
1168+
Initial shape was set
1169+
-1 - ERROR
1170+
Could not set initial shape
1171+
"""
11581172

11591173
return function
11601174

@@ -1259,6 +1273,7 @@ def __init__(self, convert_nbody=None, **options):
12591273
**options
12601274
)
12611275

1276+
12621277
def define_state(self, handler):
12631278
GravitationalDynamics.define_state(self, handler)
12641279
GravityFieldCode.define_state(self, handler)
@@ -1269,12 +1284,12 @@ def define_state(self, handler):
12691284

12701285
self.stopping_conditions.define_state(handler)
12711286

1287+
12721288
def define_methods(self, handler):
12731289
"""
12741290
Map legacy functions in TidymessInterface into
12751291
Tidymess user methods.
12761292
"""
1277-
12781293
GravitationalDynamics.define_methods(self, handler)
12791294

12801295
handler.add_method(
@@ -1564,11 +1579,13 @@ def define_parameters(self, handler):
15641579

15651580
self.stopping_conditions.define_parameters(handler)
15661581

1582+
15671583
def define_properties(self, handler):
15681584
"""Define read only properties of Tidymess"""
15691585
GravitationalDynamics.define_properties(self, handler)
15701586
handler.add_property('get_total_energy', public_name='total_energy')
15711587

1588+
15721589
def define_particle_sets(self, handler):
15731590
GravitationalDynamics.define_particle_sets(self, handler)
15741591

0 commit comments

Comments
 (0)