MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ couple()

std::pair< double, double > MayaFlux::Nodes::Network::JunctionOperator::couple ( double end_pressure,
double interior_flow )
nodiscardoverridevirtual

Advance the end cell and its coupling by one sample.

Parameters
end_pressurePressure of the end cell at the start of the sample
interior_flowVolume velocity leaving the end cell into the duct, from the same sample
Returns
The end pressure after the sample, then the volume velocity entering the duct through the end face

Implements MayaFlux::Nodes::Network::TerminationOperator.

Definition at line 415 of file TerminationOperators.cpp.

416{
417 if (!m_law) {
418 return { Acoustics::end_cell_pressure(end_pressure, m_end_gain, -interior_flow), 0.0 };
419 }
420
421 const double driving = m_driving_pressure.load(std::memory_order_relaxed);
422 const double largest = m_maximum_flow.load(std::memory_order_relaxed);
423 const double gain = Acoustics::flow_coupling_gain(m_end_gain);
424 const double target = Acoustics::flow_coupling_target(driving, end_pressure, gain, interior_flow);
425
426 const auto law = [this](double difference) -> Acoustics::FlowSample { return m_law(difference); };
427 const auto [difference, flow, status] = Acoustics::solve_pressure_flow(
428 law, gain, target, target - gain * largest, target + gain * largest, m_guess);
429
430 m_guess = difference;
431 m_status.store(static_cast<uint8_t>(status), std::memory_order_relaxed);
432 return { Acoustics::centred_end_pressure(driving, difference, end_pressure), flow };
433}

References m_driving_pressure, m_end_gain, m_guess, m_law, m_maximum_flow, and m_status.