|
Vulcan
Aerospace Engineering Utilities Built on Janus
|
Purpose: This document provides comprehensive guidance for AI agents working with the Janus library. It documents all available modules, best practices, and conventions to prevent duplication of work.
| File | Description |
|---|---|
| docs/design_overview.md | High-level architecture and design philosophy |
| docs/user_guides/symbolic_computing.md | Symbolic mode guide |
| docs/user_guides/numeric_computing.md | Numeric mode guide |
| docs/user_guides/optimization.md | Opti interface usage |
| docs/user_guides/interpolation.md | Interpolation utilities |
| docs/user_guides/graph_visualization.md | Computational graph visualization |
| docs/user_guides/sparsity.md | Sparsity pattern analysis |
| docs/user_guides/collocation.md | Direct collocation for trajectory optimization |
| docs/user_guides/multiple_shooting.md | Multiple shooting transcription |
| docs/user_guides/transcription_methods.md | Overview of trajectory optimization methods |
All physics/math functions must be templated on Scalar:
Always use Janus math functions instead of std:::
For multi-way branching, use janus::select():
| Type | Numeric Mode | Symbolic Mode |
|---|---|---|
| Scalar | double | casadi::MX |
| Matrix | Eigen::MatrixXd | Eigen::Matrix<casadi::MX> |
| Vector | Eigen::VectorXd | Eigen::Matrix<casadi::MX, Dynamic, 1> |
| File | Description | Key Functions |
|---|---|---|
| JanusTypes.hpp | Type system and aliases | sym(), sym_vec(), to_mx(), to_eigen() |
| JanusConcepts.hpp | C++20 concepts for type constraints | ScalarType, NumericScalar, SymbolicScalar |
| JanusError.hpp | Custom exception types | InvalidArgument, IntegrationError, InterpolationError |
| JanusIO.hpp | I/O and graph visualization | eval(), print(), to_dot(), graphviz() |
| Function.hpp | CasADi function wrapper | Function class for compiled symbolic functions |
| Sparsity.hpp | Sparsity pattern analysis | SparsityPattern, analyze_sparsity(), visualize_sparsity() |
Basic math operations with dual-backend support:
| Function | Description |
|---|---|
| abs(x) | Absolute value |
| sqrt(x) | Square root |
| pow(base, exp) | Power function |
| exp(x) | Exponential e^x |
| log(x) | Natural logarithm |
| log10(x) | Base-10 logarithm |
| sinh(x), cosh(x), tanh(x) | Hyperbolic functions |
| floor(x), ceil(x) | Rounding |
| remainder(x, y) | Modulo operation |
| sign(x) | Sign function |
| copysign(mag, sgn) | Copy sign |
All functions have scalar and matrix overloads.
| Function | Description |
|---|---|
| sin(x), cos(x), tan(x) | Basic trig |
| asin(x), acos(x), atan(x) | Inverse trig |
| atan2(y, x) | Two-argument arctangent |
Symbolic-compatible branching and comparisons:
| Function | Description |
|---|---|
| where(cond, if_true, if_false) | Ternary selection |
| select(conditions, values, default) | Multi-way selection |
| min(a, b), max(a, b) | Min/max |
| clamp(val, low, high) | Clamping |
| lt(a, b), gt(a, b), le(a, b), ge(a, b), eq(a, b), neq(a, b) | Element-wise comparisons |
| sigmoid_blend(x, val_low, val_high, sharpness) | Smooth blending |
| blend(x, val_low, val_high, center, sharpness) | Centered blending |
| Function | Description |
|---|---|
| gradient(f, x) | Gradient of scalar function |
| jacobian(f, x) | Jacobian matrix |
| hessian(f, x) | Hessian matrix |
| trapz(y, x) | Trapezoidal integration |
| diff(y, x) | Numerical differentiation |
| cumsum(y) | Cumulative sum |
| Function | Description |
|---|---|
| jacobian({outputs}, {inputs}) | Multi-input/output Jacobian |
| hessian(output, inputs) | Hessian matrix |
| Function | Description |
|---|---|
| dot(a, b) | Dot product |
| cross(a, b) | Cross product (3D) |
| norm(v) | Euclidean norm |
| normalize(v) | Unit vector |
| trace(M) | Matrix trace |
| det(M) | Determinant |
| inv(M) | Matrix inverse |
| reshape(M, rows, cols) | Reshape matrix |
| eye<Scalar>(n) | Identity matrix |
| zeros<Scalar>(rows, cols) | Zero matrix |
| ones<Scalar>(rows, cols) | Ones matrix |
| block_diag(blocks) | Block diagonal matrix |
| Function | Description |
|---|---|
| interp1(x, xp, fp) | 1D linear interpolation |
| interp1(x, table, method) | 1D with method selection |
| interp_nd(point, table) | N-dimensional interpolation |
| InterpolatedModel::fit(x, y) | Fit interpolation model |
Methods: "linear", "cubic", "monotonic"
| Function | Description |
|---|---|
| linspace(start, end, n) | Linear spacing |
| cosspace(start, end, n) | Cosine spacing (clusters at ends) |
| sinspace(start, end, n) | Sine spacing |
| logspace(start, end, n) | Logarithmic spacing |
| geomspace(start, end, n) | Geometric spacing |
ODE integration:
| Function | Description |
|---|---|
| quad(f, a, b) | Definite integral (Gauss-Kronrod) |
| solve_ivp(dynamics, x0, t_span) | ODE IVP solver |
Integration methods: "RK4", "CVODES", "IDAS"
Symbolic-friendly discrete integration:
| Function | Description |
|---|---|
| integrate_discrete(y, x, method) | Discrete integration |
Methods: "rectangular", "trapezoidal", "simpson", "cubic", "squared_curvature"
| Function | Description |
|---|---|
| finite_difference_coefficients(derivative_order, x, x0) | FD coefficients |
| Function | Description |
|---|---|
| rotation_2d(angle) | 2D rotation matrix |
| rotation_x(angle) | Rotation about X axis |
| rotation_y(angle) | Rotation about Y axis |
| rotation_z(angle) | Rotation about Z axis |
Full quaternion algebra class:
| Method | Description |
|---|---|
| Quaternion(w, x, y, z) | Constructor |
| Quaternion::from_axis_angle(axis, angle) | From axis-angle |
| Quaternion::from_dcm(dcm) | From rotation matrix |
| q.inverse(), q.conjugate() | Inverse/conjugate |
| q.normalize() | Normalize |
| q.rotate(v) | Rotate vector |
| q.to_dcm() | Convert to DCM |
| q.to_euler_zyx() | Convert to Euler angles |
| slerp(q1, q2, t) | Spherical interpolation |
| Function | Description |
|---|---|
| bisection(f, a, b) | Bisection method |
| newton(f, df, x0) | Newton-Raphson |
| find_root(f, x0) | Automatic method selection |
Smooth approximations:
| Function | Description |
|---|---|
| softmax(x, sharpness) | Smooth maximum |
| softmin(x, sharpness) | Smooth minimum |
| softabs(x, sharpness) | Smooth absolute value |
| sigmoid(x) | Logistic sigmoid |
| tanh_blend(x, low, high, center, width) | Tanh blending |
Main optimization interface:
Collocation (Collocation.hpp):
Multiple Shooting (MultiShooting.hpp):
Before implementing new functionality, check these existing guides to avoid duplication:
| Guide | File | Topics Covered |
|---|---|---|
| Numeric Computing | docs/user_guides/numeric_computing.md | Numeric mode, evaluation, standard execution |
| Symbolic Computing | docs/user_guides/symbolic_computing.md | Symbolic mode, graph building, MX operations |
| Optimization | docs/user_guides/optimization.md | Opti interface, constraints, solving |
| Interpolation | docs/user_guides/interpolation.md | 1D/ND interp, methods, caching |
| Graph Visualization | docs/user_guides/graph_visualization.md | DOT export, Graphviz, debugging |
| Sparsity | docs/user_guides/sparsity.md | Sparsity patterns, Jacobian structure |
| Collocation | docs/user_guides/collocation.md | Direct collocation transcription |
| Multiple Shooting | docs/user_guides/multiple_shooting.md | Multiple shooting transcription |
| Transcription Methods | docs/user_guides/transcription_methods.md | Comparison of trajectory methods |
| Math Functions | docs/user_guides/math_functions.md | Overview of janus:: math functions |
The following functionality already exists in Janus: