Skip to content

Commit

Permalink
document the addition of a unit_converter
Browse files Browse the repository at this point in the history
  • Loading branch information
ipelupessy committed Sep 6, 2022
1 parent 7fffbbe commit 8e3c8f6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/amuse/rfi/tools/create_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ def echo_int():
class {0.name_of_the_code_interface_class}({0.name_of_the_superclass_for_the_code_interface_class}):
def __init__(self, **options):
# the following alternative __init__ signature is appropiate for codes that use an unspecified unit system
# (ie the quantities have dimension but no definite scale)
$
# def __init__(self, unit_converter=None, **options):
# self.unit_converter=unit_converter
#
# in this case you also need to use the define_converter below
{0.name_of_the_superclass_for_the_code_interface_class}.__init__(self, {0.name_of_the_community_interface_class}(**options), **options)
# typically the high level specification also contains the following:
Expand Down Expand Up @@ -88,6 +97,15 @@ def define_grids(self, handler):
# handler.add_setter('grid', 'set_rho', names=["density"])
pass
# this handles unit conversion if an (optional) unit converter is specified
# def define_converter(self, handler):
# if self.unit_converter is not None:
# handler.set_converter(
# self.unit_converter.as_converter_from_si_to_generic()
# )
"""

test_file_template = """\
Expand Down

0 comments on commit 8e3c8f6

Please sign in to comment.