Modifying the bodies

Once all settings for the bodies are defined as described in Creating the bodies, the bodies are created and linked together, so that all required interdependencies are automatically satisfied.

Adding bodies to an existing SystemOfBodies

After creating a SystemOfBodies from body settings, any number of additional custom bodies may be added to the simulation. Such an approach can be useful when:

  • Wanting to create a body that has a custom environment model that depends on the other bodies (such as aerodynamic guidance, thrust guidance, etc.), see Custom models for a detailed set of options.

  • Wanting to add bodies to an existing system of bodies in a simulation loop

One crucial downside of adding bodies to an existing SystemOfBodies is that the dependencies between the bodies can only go in ‘one direction’: the newly added body may depend on the existing bodies, but the existing bodies can typically not be updated to depend on the newly added body. Therefore, manually adding bodies to an existing system of bodies is typically limited to spacecraft, for which their properties will (usually) not influence other bodies.

Warning

The (semi-)manual creation of bodies, or the modification of environment models of existing bodies, is not the recommended approach to take. Unless you have a good reason to take this approach (such as those listed above), we recommend the creation of bodies using creation of body settings

The first step is to add an empty Body object to the existing SystemOfBodies object through its create_empty_body() method:

Required Show/Hide

# import statements required
from tudatpy.kernel.numerical_simulation import environment_setup
from tudatpy.kernel.interface import spice

# load spice kernels
spice_interface.load_standard_kernels()
# define bodies in simulation
bodies_to_create = ["Sun", "Earth", "Moon", "Mars", "Jupiter"]

# create body settings dictionary
global_frame_origin = "SSB"
global_frame_orientation = "J2000"
body_settings = environment_setup.get_default_body_settings(
        bodies_to_create, global_frame_origin, global_frame_orientation)
# Create system of bodies from the body settings
bodies = environment_setup.create_system_of_bodies(body_settings)
# Add empty body to simulation
body_system.create_empty_body( "Vehicle" )

which adds a body with no properties to the system.

Addition of properties to a body

Properties can be added to an existing body after the body’s creation (with the limitations mentioned above). For an artificial body, typical properties are:

  • Rigid body model (mass, center of mass, inertia tensor), using the add_rigid_body_properties() function

  • Aerodynamic coefficients, using the add_aerodynamic_coefficient_interface() function

  • Radiation pressure target model, using the add_radiation_pressure_target_model() function

  • Engine model, using the add_engine_model() or add_variable_direction_engine_model() function

  • Rotation model, using the add_rotation_model() function

    Required Show/Hide

    # import statements required
    from tudatpy.kernel.numerical_simulation import environment_setup
    from tudatpy.kernel.interface import spice
    
    # load spice kernels
    spice_interface.load_standard_kernels()
    
    # define bodies in simulation
    bodies_to_create = ["Sun", "Earth", "Moon", "Mars", "Jupiter"]
    
    # create body settings dictionary
    global_frame_origin = "SSB"
    global_frame_orientation = "J2000"
    body_settings = environment_setup.get_default_body_settings(
            bodies_to_create, global_frame_origin, global_frame_orientation)
    
    # Create system of bodies from the body settings
    bodies = environment_setup.create_system_of_bodies(body_settings)
    
    # Add empty body to simulation
    body_system.create_empty_body( "Vehicle" )
    
    # Set mass of vehicle
    bodies.get( "Vehicle").mass = 5000.0
    
    # Alternative, more extensive, approach to do the same (add constant mass)
    #rigid_body_properties = environment_setup.rigid_body.constant_rigid_body_properties( 5000.0 )
    #environment_setup.add_rigid_body_properties( bodies, "Vehicle", rigid_body_properties )
    
    # Create aerodynamic coefficient interface settings, and add to vehicle
    aero_coefficient_settings = environment_setup.aerodynamic_coefficients.constant(
        reference_area = 50.0,
        constant_force_coefficient = [drag_coefficient,0,0]
    )
    environment_setup.add_aerodynamic_coefficient_interface(
                bodies, "Vehicle", aero_coefficient_settings );
    
    # Create radiation pressure settings, and add to vehicle
    radiation_pressure_settings = environment_setup.radiation_pressure.cannonball(
        source_body = "Sun", 
        reference_area = 50.0, 
        radiation_pressure_coefficient = 1.5, 
        occulting_bodies = ["Earth"]
    )
    environment_setup.add_radiation_pressure_target_model(
                bodies, "Vehicle", radiation_pressure_settings );
    

Note

For the addition of the mass, we use the shorthand mass attribute of the Body class. Modifying this attribute is equivalent to the second (commented) method to add a mass to a vehicle using the add_rigid_body_properties() function. The mass is an atypical property, for which we support the direct setting through the Body class, without going through a constituent environment model. We stress that this is merely an interface of convenience, and the (commented) interface in the above code snippet represents the ‘formal’ way of doing things.

In this example, the settings for the aerodynamic coefficients and radiation pressure are defined as the most simple models available (constant drag-only aerodynamic coefficients, and cannonball radiation pressure). The above approach uses the settings for environment models, just as the creation of bodies from settings (which is the preferred and recommended approach in most cases). However, instead of storing these environment settings in a larger object defining the settings for the full bodies, and for all bodies together, here we use the environment model settings one at a time. For each supported environment model, an add.... function is provided in the environment_setup module.

Note that a similar approach is typically taken to add ground stations to a body (see ground_stations)

See also

An overview of model types, as well as some special considerations to keep in mind when using them, can be found in Available Model Types.