test_motorThermal
- test_motorThermal.referenceTemperatures(scenario, times)[source]
Reproduce the module heat balance step-by-step for the given log times.
This mirrors
MotorThermal::computeTemperature:wheelPower = Omega * u_currentfrictionHeat = Omega * frictionTorqueheatGeneration = dt * (|wheelPower| / eff * (1 - eff) + |frictionHeat|)heatDissipation = dt * (T - T_ambient) / RT <- T + (heatGeneration - heatDissipation) / C
dtis taken from the spacing of the recorder time stamps so the reference uses exactly the same time step the module saw (the module computesdt = CurrentSimNanos - prevTimeand starts withprevTimeat the simulation start time).
- test_motorThermal.runScenario(scenario)[source]
Drive the motorThermal module with a standalone reaction wheel state message holding constant, fully-controlled inputs. Returns the recorded log times (in nanoseconds) and the temperature history.
- test_motorThermal.test_motorThermal(show_plots, scenario, accuracy)[source]
Validation Test Description
This unit test validates the C++ Module: motorThermal heat-balance model by feeding it a stand-alone reaction wheel state message with fully controlled wheel speed, motor torque and friction torque. Because the inputs are known exactly, the expected temperature history is derived analytically from the module equations instead of being compared against a stored regression vector of “magic” truth numbers.
Five scenarios each isolate one part of the model:
dissipation_cooling/dissipation_warming: with no wheel power and no friction the only active term is heat dissipation, so the temperature must move monotonically toward the ambient temperature (down when the motor is hotter, up when it is colder).inefficiency_only: with friction disabled and the motor starting at the ambient temperature, the first-step temperature rise must equal the motor power inefficiency contributiondt * |Omega * u_current| / eff * (1 - eff) / C.friction_only: with the motor torque set to zero (which removes the inefficiency term for any efficiency) and the motor starting at ambient, the first-step temperature rise must equal the friction contributiondt * |Omega * frictionTorque| / C.combined: all three terms active at once, checked against the full analytic heat-balance recurrence.
Every scenario also checks the complete temperature history against the step-by-step analytic recurrence to the supplied accuracy.
Test Parameters
- Parameters:
accuracy (float) – absolute accuracy used to compare the module output to the analytic reference temperatures.
Description of Variables Being Tested
The recorded
temperaturehistory is compared element-by-element againstreferenceTemperatures, and the first-step temperature change is compared against the closed-form contribution of the mechanism isolated by each scenario.
- test_motorThermal.test_motorThermal_integration(show_plots)[source]
Validation Test Description
Integration check that C++ Module: motorThermal works when wired to a live C++ Module: reactionWheelStateEffector (the connection used in real scenarios such as scenarioTempMeasurementAttitude), rather than to a stand-alone message. A single reaction wheel is spun under a constant motor torque with friction enabled and the motor starts at the ambient temperature.
Because the wheel speed, motor torque and friction torque evolve with the reaction wheel dynamics, this scenario does not assert exact temperatures (those are covered analytically in
test_motorThermal). It verifies the end-to-end message path instead: the temperatures must stay finite (noNaNfrom an unconnected or mis-typed message) and the motor must heat up, since a spinning, loaded wheel generates heat and there is no dissipation at the starting ambient temperature.
- test_motorThermal.test_motorThermal_resetErrors(show_plots, brokenPrecondition, expectedMessage)[source]
Validation Test Description
Checks that C++ Module: motorThermal rejects an invalid configuration at
Reset()instead of running with it. Each case starts from a valid module and breaks one precondition, then asserts that initialization raises aBasiliskErrornaming the offending quantity. These guards were previously untested.