How openmdao/cadre works
Project Type and Purpose
• This is a Python-based scientific/engineering library implementing the CADRE CubeSat design problem using the OpenMDAO framework.
• Its primary purpose is to model and optimize satellite subsystems (power, attitude, communication, thermal, propulsion, etc.) via a composite OpenMDAO Group and optionally drive a Markov Decision Process (MDP) solver or an optimizer (SNOPT, MPI-parallel runs with PETSc4py).
File Structure Analysis
• Top level:
• CADRE/ ← Package source
• examples/ ← Entry-point scripts demonstrating usage
• benchmark/, profile/ ← Performance tests
• .github/, CI config
• pyproject.toml ← Build and dependency metadata
• CADRE/ directory:
• CADRE_group.py ← Assembles the OpenMDAO model (Group)
• CADRE_mdp.py ← Defines the MDP formulation for discrete decision problems
• Modules for each subsystem: attitude.py, battery.py, comm.py, kinematics.py, orbit.py, power.py, reactionwheel.py, solar.py, sun.py, thermal_temperature.py
• integrators: explicit.py, rk4.py
• parameters.py ← Shared input parameters
• data/ ← Tables and files used by subsystem models
• test/ ← Unit tests and pickled test data
Key Insights from README
• Relies on OpenMDAO 3.x, optional dependencies for optimization (pyOptSparse/SNOPT) and parallel runs (mpi4py, petsc4py).
• Contains examples (mdp.py, mppt.py, plot_progress.py) illustrating how to instantiate and run the model.
Main Components
• User Entry Points (examples/*.py)
• CADRE_group (OpenMDAO Group)
• Subsystem Components (one per Python module: Power, Solar, Battery, Comm, Attitude, ReactionWheel, Kinematics, Orbit, Thermal, Sun)
• Numerical Tools (RK4 integrator, explicit derivative methods)
• MDP Solver (CADRE_mdp)
• Data Sources (CSV, DAT, Fortran scripts under CADRE/data)
• Optimization Layer (pyOptSparse→SNOPT or OpenMDAO drivers)
• Parallel Infrastructure (mpi4py → PETSc4py)
• Output/Visualization (plot_progress example, console logs, benchmark outputs)
Relationships and Data Flow
• Example script → instantiates CADRE_group → supplies parameters →
• Data Sources feed initialization of subsystem components
• Each component computes outputs (power generation, battery state, attitude control torques, communication link margins, thermal balance)
• RK4/explicit integrate dynamic states over time
• CADRE_group collects outputs, computes objective(s) & constraints
• For MDP problems: CADRE_mdp orchestrates sequences of calls to the OpenMDAO model
• Optimization driver (SNOPT or OpenMDAO’s built-in drivers) interrogates CADRE_group via fwd/rev mode for gradients
• For parallel runs: driver and model distributed via MPI/PETSc
• Final results passed back to user or written to disk
Architectural Patterns and Design Principles
• Modular component architecture: each subsystem is an independent OpenMDAO Component
• Composite pattern: CADRE_group assembles subsystems into a coupled system
• Separation of concerns: data, model definition, integration, optimization, and test code live in distinct folders
• Extensibility via standard OpenMDAO APIs: adding new subsystems or solvers
• Optional parallelism and pluggable optimizers