Fix bugs from 5-2 code review
This commit is contained in:
@@ -59,6 +59,8 @@ pub mod compressor;
|
||||
pub mod expansion_valve;
|
||||
pub mod external_model;
|
||||
pub mod fan;
|
||||
pub mod flow_boundary;
|
||||
pub mod flow_junction;
|
||||
pub mod heat_exchanger;
|
||||
pub mod pipe;
|
||||
pub mod polynomials;
|
||||
@@ -84,6 +86,14 @@ pub use polynomials::{AffinityLaws, PerformanceCurves, Polynomial1D, Polynomial2
|
||||
pub use port::{
|
||||
validate_port_continuity, Connected, ConnectedPort, ConnectionError, Disconnected, FluidId, Port,
|
||||
};
|
||||
pub use flow_boundary::{
|
||||
CompressibleSink, CompressibleSource, FlowSink, FlowSource,
|
||||
IncompressibleSink, IncompressibleSource,
|
||||
};
|
||||
pub use flow_junction::{
|
||||
CompressibleMerger, CompressibleSplitter, FlowMerger, FlowSplitter, FluidKind,
|
||||
IncompressibleMerger, IncompressibleSplitter,
|
||||
};
|
||||
pub use pump::{Pump, PumpCurves};
|
||||
pub use state_machine::{
|
||||
CircuitId, OperationalState, StateHistory, StateManageable, StateTransitionError,
|
||||
@@ -499,6 +509,39 @@ pub trait Component {
|
||||
/// assert!(component.get_ports().is_empty());
|
||||
/// ```
|
||||
fn get_ports(&self) -> &[ConnectedPort];
|
||||
|
||||
/// Injects system-level context into a component during topology finalization.
|
||||
///
|
||||
/// Called by [`System::finalize()`] after all edge state indices are computed.
|
||||
/// The default implementation is a no-op; override this in components that need
|
||||
/// to know their position in the global state vector (e.g. `MacroComponent`).
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `state_offset` — The index in the global state vector where this component's
|
||||
/// *internal* state block begins. For ordinary leaf components this is never
|
||||
/// needed; for `MacroComponent` it replaces the manual `set_global_state_offset`
|
||||
/// call.
|
||||
/// * `external_edge_state_indices` — A slice of `(p_idx, h_idx)` pairs for every
|
||||
/// edge incident to this component's node in the parent graph (incoming and
|
||||
/// outgoing), in traversal order. `MacroComponent` uses these to emit
|
||||
/// port-coupling residuals.
|
||||
fn set_system_context(
|
||||
&mut self,
|
||||
_state_offset: usize,
|
||||
_external_edge_state_indices: &[(usize, usize)],
|
||||
) {
|
||||
// Default: no-op for all ordinary leaf components.
|
||||
}
|
||||
|
||||
/// Returns the number of internal state variables this component maintains.
|
||||
///
|
||||
/// The default implementation returns 0, which is correct for all ordinary
|
||||
/// leaf components. Hierarchical components (like `MacroComponent`) should
|
||||
/// override this to return the size of their internal state block.
|
||||
fn internal_state_len(&self) -> usize {
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user