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 not always be (easily) updated to depend on the newly added body.

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
# import statements required
from tudatpy.dynamics import environment_setup
from tudatpy.interface import spice

# load spice kernels
spice.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:

Required
# import statements required
from tudatpy.dynamics import environment_setup
from tudatpy.interface import spice

# load spice kernels
spice.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_radiation_target(
    reference_area = 50.0, 
    radiation_pressure_coefficient = 1.5, 
    per_source_occulting_bodies = {"Sun": ["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 Station Creation)