This script sets up a 3-DOF spacecraft which is orbiting the with a magnetic field model. This scenario is similar to the centered dipole model scenarioMagneticFieldCenteredDipole, but here the World Magnetic Model (WMM) is employed. This model is specific to Earth and not suitable for other planets. The purpose is to illustrate how to create and setup the WMM magnetic field, as well as determine the magnetic field at a spacecraft location. The orbit setup is similar to that used in scenarioBasicOrbit.

The script is found in the folder basilisk/examples and executed by using:


Simulation Scenario Setup Details

The simulation layout is shown in the following illustration. A single simulation process is created which contains the spacecraft object. The spacecraft state message is connected to the magnetic field module which outputs the local magnetic field in inertial frame components.


When the simulation completes 2 plots are shown for each case. One plot always shows the inertial position vector components, while the second plot shows the local magnetic field vector components with respect to the inertial frame.

As this Module: magneticFieldWMM model is specific to Earth, there are no parameters to set of tune. Rather, the WMM.COF WMM coefficient file is loaded from the dataPath variable.

The default planet’s position vector is assumed to be the inertial frame origin and an identity orientation matrix. If a different planet state message is required this can be specified through the optional input message planetPosInMsgName.

As with scenarioMagneticFieldCenteredDipole, the magnetic field module can produce the magnetic field for a vector of spacecraft locations, not just for a single spacecraft.

The WMM module requires an epoch time to determine the magnetic field. If this is not set, then the BSK default epoch time is used. To set a general epoch time, the module can read in an epoch message with a gregorian UTC date. This is set using the the support method timeStringToGregorianUTCMsg.

The WMM model is driven of a time variable that is a decimal year value. The module can set this as well by specifying the module parameter epochDateFractionalYear. However, note that if the epoch message is specified, the message information is used instead of the epochDateFractionalYear variable.

Every time a spacecraft is added to the magnetic field module, an automated output message name is created. For magModule is “WMM_0_data” as the ModelTag string is WMM and the spacecraft number is 0. This output name is created in the addSpacecraftToModel() function. However, if the default output name is used for the second planetary magnetic field model, then both module share the same output name and one will overwrite the others output.

The reach of the magnetic field model is specified through the module variables envMinReach and envMaxReach. Their default values are -1 which turns off this feature, giving the magnetic field evaluation infinite reach.

Illustration of Simulation Results

The following images illustrate the expected simulation run returns for a range of script configurations.

show_plots = True, orbitCase='circular'
show_plots = True, orbitCase='elliptical'
../_images/scenarioMagneticFieldWMM1elliptical.svg../_images/scenarioMagneticFieldWMM2elliptical.svg, orbitCase)[source]

At the end of the python script you can specify the following example parameters.

  • show_plots (bool) – Determines if the script should display plots

  • orbitCase (str) – {‘circular’, ‘elliptical’}