本文整理汇总了Python中amuse.community.interface.common.CommonCode类的典型用法代码示例。如果您正苦于以下问题:Python CommonCode类的具体用法?Python CommonCode怎么用?Python CommonCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommonCode类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: define_state
def define_state(self, object):
CommonCode.define_state(self, object)
object.add_transition('INITIALIZED','EDIT','commit_parameters')
object.add_transition('RUN','CHANGE_PARAMETERS_RUN','before_set_parameter', False)
object.add_transition('EDIT','CHANGE_PARAMETERS_EDIT','before_set_parameter', False)
object.add_transition('UPDATE','CHANGE_PARAMETERS_UPDATE','before_set_parameter', False)
object.add_transition('CHANGE_PARAMETERS_RUN','RUN','recommit_parameters')
object.add_transition('CHANGE_PARAMETERS_EDIT','EDIT','recommit_parameters')
object.add_transition('CHANGE_PARAMETERS_UPDATE','UPDATE','recommit_parameters')
object.add_method('CHANGE_PARAMETERS_RUN', 'before_set_parameter')
object.add_method('CHANGE_PARAMETERS_EDIT', 'before_set_parameter')
object.add_method('CHANGE_PARAMETERS_UPDATE','before_set_parameter')
object.add_method('CHANGE_PARAMETERS_RUN', 'before_get_parameter')
object.add_method('CHANGE_PARAMETERS_EDIT', 'before_get_parameter')
object.add_method('CHANGE_PARAMETERS_UPDATE','before_get_parameter')
object.add_method('RUN', 'before_get_parameter')
object.add_method('EDIT', 'before_get_parameter')
object.add_method('UPDATE','before_get_parameter')
object.add_transition('EDIT', 'UPDATE', 'generate_particles', False)
object.add_transition('UPDATE', 'RUN', 'update_particle_set')
object.add_transition('RUN', 'EDIT', 'clear_particle_set')
object.add_method('RUN', 'invoke_state_change_updated')
object.add_method('EDIT', 'get_number_of_particles_updated')
object.add_method('UPDATE', 'get_number_of_particles_updated')
object.add_method('RUN', 'get_number_of_particles_updated')
object.add_method('RUN', 'get_mass')
object.add_method('RUN', 'get_position')
object.add_method('RUN', 'get_velocity')
示例2: define_state
def define_state(self, object):
CommonCode.define_state(self, object)
for method_name in [
'initialize_from_dyn',
'initialize_from_elements',
'transform_to_time',
'advance_to_radius',
'return_to_radius',
'advance_to_periastron',
'advance_to_apastron',
'return_to_periastron',
'return_to_apastron',
'get_total_mass',
'get_time',
'get_period',
'get_elements',
'get_integrals',
'get_separation_vector',
'get_separation',
'set_periastron',
'get_periastron',
'get_apastron',
'get_velocity_vector',
'get_angles',
'set_longitudinal_unit_vector',
'set_normal_unit_vector',
'get_longitudinal_unit_vector',
'get_transverse_unit_vector',
'set_transverse_unit_vector',
'get_normal_unit_vector',
'print_all',
'set_random',
'get_random',
'make_binary_scattering']:
object.add_method('!UNINITIALIZED!END', method_name)
示例3: define_methods
def define_methods(self, object):
CommonCode.define_methods(self, object)
object.add_method("generate_particles", (), (object.ERROR_CODE,))
object.add_method("get_number_of_particles_updated", (), (object.NO_UNIT,object.NO_UNIT, object.ERROR_CODE,))
object.add_method("get_mass", (object.INDEX,),
(nbody_system.mass, object.ERROR_CODE)
)
object.add_method("get_position", (object.INDEX,),
(nbody_system.length, nbody_system.length, nbody_system.length, object.ERROR_CODE)
)
object.add_method("get_velocity", (object.INDEX,),
(nbody_system.speed, nbody_system.speed, nbody_system.speed, object.ERROR_CODE)
)
object.add_method("get_output_path", (), (object.NO_UNIT, object.ERROR_CODE,))
object.add_method("set_output_path", (object.NO_UNIT,), (object.ERROR_CODE,))
for par in parameters:
if hasattr(parameters[par]["default"],"unit"):
unit=parameters[par]["default"].unit
else:
unit=object.NO_UNIT
object.add_method("get_"+par, (), (unit, object.ERROR_CODE,))
object.add_method("set_"+par, (unit, ), (object.ERROR_CODE,))
示例4: define_state
def define_state(self, object):
CommonCode.define_state(self, object)
object.add_transition('INITIALIZED','EDIT','commit_parameters')
object.add_transition('RUN','CHANGE_PARAMETERS_RUN','before_set_parameter', False)
object.add_transition('EDIT','CHANGE_PARAMETERS_EDIT','before_set_parameter', False)
object.add_transition('UPDATE','CHANGE_PARAMETERS_UPDATE','before_set_parameter', False)
object.add_transition('CHANGE_PARAMETERS_RUN','RUN','recommit_parameters')
object.add_transition('CHANGE_PARAMETERS_EDIT','EDIT','recommit_parameters')
object.add_transition('CHANGE_PARAMETERS_UPDATE','UPDATE','recommit_parameters')
object.add_method('CHANGE_PARAMETERS_RUN', 'before_set_parameter')
object.add_method('CHANGE_PARAMETERS_EDIT', 'before_set_parameter')
object.add_method('CHANGE_PARAMETERS_UPDATE','before_set_parameter')
object.add_method('CHANGE_PARAMETERS_RUN', 'before_get_parameter')
object.add_method('CHANGE_PARAMETERS_EDIT', 'before_get_parameter')
object.add_method('CHANGE_PARAMETERS_UPDATE','before_get_parameter')
object.add_method('RUN', 'before_get_parameter')
object.add_method('EDIT', 'before_get_parameter')
object.add_method('UPDATE','before_get_parameter')
object.add_method('EVOLVED','before_get_parameter')
object.add_method('EDIT', 'new_gas_particle')
object.add_method('EDIT', 'remove_gas_particle')
object.add_method('EDIT', 'new_src_particle')
object.add_method('EDIT', 'remove_src_particle')
object.add_transition('EDIT', 'RUN', 'commit_particles')
object.add_transition('RUN', 'UPDATE', 'new_gas_particle', False)
object.add_transition('RUN', 'UPDATE', 'remove_gas_particle', False)
object.add_transition('RUN', 'UPDATE', 'new_src_particle', False)
object.add_transition('RUN', 'UPDATE', 'remove_src_particle', False)
object.add_transition('RUN', 'UPDATE', 'set_pos_gas', False)
object.add_transition('RUN', 'UPDATE', 'set_rho_gas', False)
object.add_transition('RUN', 'UPDATE', 'set_hsml_gas', False)
object.add_transition('RUN', 'UPDATE', 'set_u_gas', False)
object.add_transition('RUN', 'UPDATE', 'set_dudt_gas', False)
object.add_transition('RUN', 'UPDATE', 'set_state_gas', False)
object.add_transition('RUN', 'UPDATE', 'set_state_src', False)
object.add_transition('RUN', 'UPDATE', 'set_luminosity_src', False)
object.add_transition('UPDATE', 'RUN', 'recommit_particles')
object.add_method('RUN', 'evolve_model')
object.add_method('RUN', 'get_state_gas')
object.add_method('RUN', 'get_state_src')
object.add_method('INITIALIZED', 'set_momentum_kicks')
object.add_method('INITIALIZED', 'set_isothermal')
object.add_method('INITIALIZED', 'set_boxsize')
object.add_method('INITIALIZED', 'set_globalHefraction')
object.add_method('INITIALIZED', 'set_raynumber')
object.add_method('INITIALIZED', 'set_iontempsolver')
object.add_method('INITIALIZED', 'set_boundary')
object.add_method('INITIALIZED', 'set_H_caseA')
object.add_method('INITIALIZED', 'set_He_caseA')
示例5: define_methods
def define_methods(self, object):
CommonCode.define_methods(self, object)
object.add_method(
"new_particle",
(units.MSun,),
(object.INDEX, object.ERROR_CODE,)
)
object.add_method(
"delete_particle",
(object.INDEX,),
(object.ERROR_CODE,)
)
object.add_method(
"read_usm",
(object.NO_UNIT,),
(object.INDEX, object.ERROR_CODE,)
)
object.add_method(
"add_shell",
(object.INDEX, units.MSun, units.MSun, units.RSun, units.g / units.cm**3, units.barye,
units.K, units.LSun, units.amu, object.NO_UNIT, object.NO_UNIT, object.NO_UNIT, object.NO_UNIT,
object.NO_UNIT, object.NO_UNIT, object.NO_UNIT, object.NO_UNIT, object.NO_UNIT),
(object.ERROR_CODE,)
)
object.add_method(
"get_stellar_model_element",
(object.INDEX, object.INDEX,),
(units.MSun, units.MSun, units.RSun, units.g / units.cm**3, units.barye,
object.NO_UNIT, units.K, units.LSun, units.amu,
object.NO_UNIT, object.NO_UNIT, object.NO_UNIT, object.NO_UNIT, object.NO_UNIT,
object.NO_UNIT, object.NO_UNIT, object.NO_UNIT, object.NO_UNIT, object.ERROR_CODE,)
)
object.add_method(
"get_number_of_zones",
(object.INDEX, ),
(object.NO_UNIT, object.ERROR_CODE,)
)
object.add_method(
"get_number_of_particles",
(),
(object.NO_UNIT, object.ERROR_CODE,)
)
object.add_method(
"merge_two_stars",
(object.INDEX, object.INDEX,),
(object.INDEX, object.ERROR_CODE,)
)
object.add_method("get_target_n_shells_mixing", (), (object.NO_UNIT, object.ERROR_CODE,))
object.add_method("set_target_n_shells_mixing", (object.NO_UNIT, ), (object.ERROR_CODE,))
object.add_method("get_target_n_shells", (), (object.NO_UNIT, object.ERROR_CODE,))
object.add_method("set_target_n_shells", (object.NO_UNIT, ), (object.ERROR_CODE,))
object.add_method("get_number_of_particles", (), (object.NO_UNIT, object.ERROR_CODE,))
示例6: define_methods
def define_methods(self, object):
CommonCode.define_methods(self, object)
object.add_method("new_particle", [nbody_system.mass] + [nbody_system.length]*3,
(object.INDEX, object.ERROR_CODE))
object.add_method(
"get_eps2",
(),
(nbody_system.length * nbody_system.length, object.ERROR_CODE,)
)
object.add_method(
"set_eps2",
(nbody_system.length * nbody_system.length, ),
(object.ERROR_CODE,)
)
示例7: define_methods
def define_methods(self, object):
CommonCode.define_methods(self, object)
object.add_method("generate_particles", (), (object.ERROR_CODE,))
object.add_method("get_number_of_particles_updated", (), (object.NO_UNIT, object.ERROR_CODE))
object.add_method(
"get_state", (object.INDEX,), [nbody_system.length] * 3 + [nbody_system.speed] * 3 + [object.ERROR_CODE]
)
object.add_method("get_target_number_of_particles", (), (object.NO_UNIT, object.ERROR_CODE))
object.add_method("set_target_number_of_particles", (object.NO_UNIT,), (object.ERROR_CODE,))
object.add_method("get_fractal_dimension", (), (object.NO_UNIT, object.ERROR_CODE))
object.add_method("set_fractal_dimension", (object.NO_UNIT,), (object.ERROR_CODE,))
object.add_method("get_random_seed", (), (object.NO_UNIT, object.ERROR_CODE))
object.add_method("set_random_seed", (object.NO_UNIT,), (object.ERROR_CODE,))
示例8: define_state
def define_state(self, object):
CommonCode.define_state(self, object)
object.add_transition("INITIALIZED", "EDIT", "commit_parameters")
object.add_transition("EDIT", "CHANGE_PARAMETERS_EDIT", "before_set_parameter", False)
object.add_transition("CHANGE_PARAMETERS_EDIT", "EDIT", "recommit_parameters")
object.add_method("CHANGE_PARAMETERS_EDIT", "before_set_parameter")
object.add_method("CHANGE_PARAMETERS_EDIT", "before_get_parameter")
object.add_method("RUN", "before_get_parameter")
object.add_method("EDIT", "before_get_parameter")
object.add_transition("EDIT", "RUN", "generate_particles", False)
object.add_transition("RUN", "EDIT", "clear_particle_set")
object.add_method("EDIT", "get_number_of_particles_updated")
object.add_method("RUN", "get_number_of_particles_updated")
object.add_method("RUN", "get_state")
示例9: define_state
def define_state(self, object):
CommonCode.define_state(self, object)
object.add_transition("INITIALIZED", "EDIT", "commit_parameters")
object.add_transition("RUN", "CHANGE_PARAMETERS_RUN", "before_set_parameter", False)
object.add_transition("EDIT", "CHANGE_PARAMETERS_EDIT", "before_set_parameter", False)
object.add_transition("UPDATE", "CHANGE_PARAMETERS_UPDATE", "before_set_parameter", False)
object.add_transition("CHANGE_PARAMETERS_RUN", "RUN", "recommit_parameters")
object.add_transition("CHANGE_PARAMETERS_EDIT", "EDIT", "recommit_parameters")
object.add_transition("CHANGE_PARAMETERS_UPDATE", "UPDATE", "recommit_parameters")
object.add_method("CHANGE_PARAMETERS_RUN", "before_set_parameter")
object.add_method("CHANGE_PARAMETERS_EDIT", "before_set_parameter")
object.add_method("CHANGE_PARAMETERS_UPDATE", "before_set_parameter")
object.add_method("CHANGE_PARAMETERS_RUN", "model_present")
object.add_method("CHANGE_PARAMETERS_EDIT", "model_present")
object.add_method("CHANGE_PARAMETERS_UPDATE", "model_present")
object.add_method("INITIALIZED", "model_present")
object.add_method("CHANGE_PARAMETERS_RUN", "before_get_parameter")
object.add_method("CHANGE_PARAMETERS_EDIT", "before_get_parameter")
object.add_method("CHANGE_PARAMETERS_UPDATE", "before_get_parameter")
object.add_method("RUN", "before_get_parameter")
object.add_method("EDIT", "before_get_parameter")
object.add_method("UPDATE", "before_get_parameter")
object.add_transition("EDIT", "UPDATE", "generate_particles", False)
object.add_transition("UPDATE", "RUN", "update_particle_set")
object.add_transition("RUN", "EDIT", "clear_particle_set")
object.add_method("RUN", "invoke_state_change_updated")
object.add_method("EDIT", "get_number_of_particles_updated")
object.add_method("UPDATE", "get_number_of_particles_updated")
object.add_method("RUN", "get_number_of_particles_updated")
object.add_method("RUN", "get_number_of_particles")
object.add_method("RUN", "get_mass")
object.add_method("RUN", "get_position")
object.add_method("RUN", "get_velocity")
示例10: __init__
def __init__(self, **options):
CommonCode.__init__(self, DistributedAmuseInterface(**options), **options)
示例11: __init__
def __init__(self, unit_converter = None, **options):
self.unit_converter = unit_converter
self.stopping_conditions = StoppingConditions(self)
CommonCode.__init__(self, CapreoleInterface(**options), **options)
示例12: __init__
def __init__(self, unit_converter = None, **options):
self.unit_converter = unit_converter
legacy_interface = BarAndSpiralsInterface(**options)
self.interface_doc = legacy_interface.__doc__
CommonCode.__init__(self, legacy_interface, **options)