continuous_blocks/lib.rs
1//! Continuous-time block-diagram elements — transfer function, state-space, PID,
2//! voltage-controlled oscillator, hysteresis (Schmitt-trigger) comparator, and stateless math
3//! ops (gain, sum, product, saturation) — matching the standard `Continuous`/`Math Operations`
4//! block sets common to block-diagram simulation tools. Each block does one
5//! job and is meant to be wired to the others by the caller — an error signal is a `Sum`
6//! block's output, not something a controller computes internally, and a frequency-modulated
7//! PWM carrier is `Pid -> Gain -> Vco`, not a single fused "closed loop" function. See
8//! `dae-runtime`'s `closed_loop` module for how a circuit's ideal-switch gates get wired to a chain
9//! of these blocks.
10//!
11//! Every dynamic block compiles to a [`StateSpace`] — the same descriptor-DAE shape
12//! `general-mna` already uses for circuits (`A x + K dx/dt = B u`, with `K` here called `e`
13//! for descriptor systems). See `docs/architecture.md`, "One descriptor system for circuit
14//! and continuous blocks alike," for why this is the organizing idea of the whole
15//! `general-simulator` project, not just this crate.
16//!
17//! This crate is deliberately standalone (no dependency on `general-mna`, `pwl-devices`, or
18//! `dae-runtime`): block parameters (gains, pole/zero locations, PID coefficients) are known
19//! numbers at model-build time, not symbolic netlist parameters, and every block here is
20//! verified against a hand-derived result on its own before anything wires it into a whole
21//! circuit's global system — the same incremental-verification discipline `lcp-solver` and
22//! `pwl-devices` were built with. Wiring a compiled block's `(A, K, B)` into `dae-runtime`'s
23//! global descriptor system, and stateless [`math_ops`] blocks into its per-timestep
24//! assembly, is a later milestone.
25
26pub mod coordinate_transforms;
27mod discrete_pid;
28mod hysteresis;
29pub mod logic;
30pub mod math_ops;
31mod pid;
32mod pmsm;
33mod state_space;
34mod transfer_function;
35mod vco;
36pub mod waveform_arithmetic;
37
38pub use coordinate_transforms::CoordinateTransform;
39pub use discrete_pid::{DiscreteIntegrationMethod, DiscretePid, DiscretePidState};
40pub use hysteresis::{Hysteresis, HysteresisError};
41pub use logic::{FlipFlopKind, LatchPriority, LogicOp};
42pub use pid::{Pid, PidError};
43pub use pmsm::{Pmsm, PmsmError};
44pub use state_space::{StateSpace, StateSpaceError};
45pub use transfer_function::{SettledStateError, TransferFunction, TransferFunctionError};
46pub use vco::{Vco, VcoError};
47pub use waveform_arithmetic::{MathFn1, MathFn2, MathFn3};