.. _scenarioMonteCarloAttRW: scenarioMonteCarloAttRW ======================= Overview -------- Demonstrates how to run basic Monte-Carlo (MC) RW-based attitude simulations. This script duplicates the scenario in :ref:`scenarioAttitudeFeedbackRW` where a 6-DOF spacecraft is orbiting the Earth. Here some simulation parameters are dispersed randomly using a multi threaded Monte-Carlo setup. Reaction Wheel (RW) state effector are added to the rigid spacecraft() hub, and what flight algorithm module is used to control these RWs. The scenario is run in a single configuration: by not using the Jitter model and by using the RW Voltage IO. Given this scenario we can add dispersions to the variables in between each MC run. The script is found in the folder ``xmera/examples`` and executed by using:: python3 scenarioMonteCarloAttRW.py For more information on the Attitude Feedback Simulation with RW, please see the documentation on the :ref:`scenarioAttitudeFeedbackRW` file. Enable Terminal Bar to Show Simulation Progress ----------------------------------------------- To enable progress bar, one need to set ``showProgressBar`` data member of class SimulationParameters to true. .. code-block:: python monteCarlo = Controller() monteCarlo.setShowProgressBar(True) Method ``setShowProgressBar`` should be used to set variable ``showProgressBar`` as True with the above statement. After enabling the progress bar, all the simulation run by ``monteCarlo.ExecuteSimulation()`` and montoCarlo.runInitialConditions will show the progress bar in the terminal. Setup Changes for Monte-Carlo Runs ---------------------------------- In order to set up the multi-threaded MC simulation, the user must first instantiate the Controller class. The function that is being simulated is the set in this class (in this case, it's defined in the same file as the MC scenario). The user can then set other variables such as the number of runs, the dispersion seeds, and number of cores. The next important step to setting up the MC runs is to disperse the necessary variables. The dispersions that are set are listed in the following table: +----------------+---------------------------+--------------------------------------------------+ | Input | Description of Element | Distribution | +================+===========================+==================================================+ | Inertial | Using Modified | Uniform for all 3 rotations between [0, 2 pi] | | attitude | Rodrigues Parameters | | +----------------+---------------------------+--------------------------------------------------+ | Inertial | Using omega vector | Normal dispersions for each of the rotation | | rotation rate | | components, each of mean 0 and standard | | | | deviation 0.25 deg/s | +----------------+---------------------------+--------------------------------------------------+ | Mass of the | Total Mass of the | Uniform around +/-5% of expected values. | | hub | spacecraft | Bounds are [712.5, 787.5] | +----------------+---------------------------+--------------------------------------------------+ | Center of Mass | Position vector offset on | Normally around a mean [0, 0, 1], with standard | | Offset | the actual center of mass,| deviations of [0.05/3, 0.05/3, 0.1/3] | | | and its theoretical | | | | position | | +----------------+---------------------------+--------------------------------------------------+ | Inertia Tensor | 3x3 inertia tensor. | Normally about mean value of diag(900, 800, 600).| | | Dispersed by 3 rotations | Each of the 3 rotations are normally distributed | | | | with angles of mean 0 and standard deviation | | | | 0.1 deg. | +----------------+---------------------------+--------------------------------------------------+ | RW axes | The rotation axis for | Normally around a respective means [1,0,0], | | | each of the 3 wheels | [0,1,0], and [0,0,1] with respective standard | | | | deviations [0.01/3, 0.005/3, 0.005/3], | | | | [0.005/3, 0.01/3, 0.005/3], and | | | | [0.005/3, 0.005/3, 0.01/3]. | +----------------+---------------------------+--------------------------------------------------+ | RW speeds | The rotation speed for | Uniform around +/-5% of expected values. Bounds | | | each of the 3 wheels | are [95, 105], [190, 210], and [285, 315] | +----------------+---------------------------+--------------------------------------------------+ | Voltage to | The gain between the | Uniform around +/-5% of expected values. Bounds | | Torque Gain | commanded torque and the | are [0.019, 0.021] | | | actual voltage | | +----------------+---------------------------+--------------------------------------------------+ Next a retention policy is used to log the desired data. The simulation can now be run. It returns the failed jobs, which should not occur. When the MC have been executed, the data can be accessed and tested in different ways. This is explained in the example python code comments. .. note:: In these Monte Carlo simulations the retained data is stored as the data array with the time information added as the first column. This is the same retained data format as used with BSK 1.x. Illustration of Simulation Results ---------------------------------- :: saveFigures = False, case = 1, show_plots = True, useDatashader = False .. image:: /_images/Scenarios/scenarioMonteCarloAttRW_AttitudeError.svg :align: center .. image:: /_images/Scenarios/scenarioMonteCarloAttRW_RateTrackingError.svg :align: center .. image:: /_images/Scenarios/scenarioMonteCarloAttRW_RWMotorTorque.svg :align: center .. image:: /_images/Scenarios/scenarioMonteCarloAttRW_RWSpeed.svg :align: center .. image:: /_images/Scenarios/scenarioMonteCarloAttRW_RWVoltage.svg :align: center