Connectors and Networks ​
A connector defines how a component interacts with its surroundings. connect(...) joins compatible connectors and generates the equations implied by their field qualifiers. Use physical connectors for conserved quantities such as current, and signal connectors for commands and measurements.
Physical ports and conservation ​
An electrical pin carries voltage and current: Download as a Dyad projectlanguage_connectors.zipOpen in Dyad Studio
connector Pin
potential v::Real
flow i::Real
endConnecting pins makes their voltages equal and generates current conservation. Current is positive into a component. Keep this convention at every component boundary; the compiler accounts for hierarchy when connecting an external port to an internal part.
A complete network ​
The following definitions form a small resistive circuit. They share the Pin definition above. The viewers show code beside the diagram when space allows; on narrower screens, use the Diagram and Code tabs.
component Resistor
parameter R::Real = 10
p = Pin()
n = Pin()
relations
p.v - n.v = R * p.i
p.i + n.i = 0
end
component VoltageSource
parameter V::Real = 5
p = Pin()
n = Pin()
relations
p.v - n.v = V
p.i + n.i = 0
end
component Ground
p = Pin()
relations
p.v = 0
endIn the viewer's code, ResistiveCircuit assembles the three parts with two connect calls. connect(source.p, load.p) joins the positive pins; connect(source.n, load.n, ground.p) joins the negative pins and ground. Select a part in the diagram to inspect its parameters.
The ground fixes the reference voltage. The source fixes the voltage difference, and the load determines the current. The three-port connection creates one connection set: its voltages are equal, and its currents satisfy source.n.i + load.n.i + ground.p.i = 0.
Physical connections express simultaneous constraints. A resistor can carry either sign of current; the connector does not impose a direction of causality on the solver.
Use partial components to share port declarations and conservation equations across a family of parts.
Causal signals ​
Signal connectors express a producer–consumer relationship. An output supplies a value; connected inputs receive it. A signal connection equates values without a conservation sum.
connector SignalInput
input value::Real
end
connector SignalOutput
output value::Real
end
component ConstantSignal
parameter k::Real = 1
y = SignalOutput()
relations
y.value = k
end
component Gain
parameter k::Real = 2
u = SignalInput()
y = SignalOutput()
relations
y.value = k * u.value
endThe viewer's SignalChain component assembles these parts with connect(source.y, gain.u). Follow that connection in the diagram, then select gain to inspect its multiplier k. With the default parameters, gain.y.value = 2.
Give a signal connection a single producer. A signal input is useful for commands and measurements; a physical flow field is useful for conserved transport.
The standard libraries provide signal connector types, including Dyad.RealInput and Dyad.RealOutput. For clock compatibility and sampling between continuous and discrete models, see Discrete-Time Modeling.
Connector field reference ​
| Field qualifier | Connection meaning | Example |
|---|---|---|
potential | Connected values are equal | Voltage, pressure |
flow | Signed flows obey conservation | Current, mass flow |
input | The component receives a signal | Controller measurement |
output | The component supplies a signal | Controller command |
stream | A flow transports an intensive property | Specific enthalpy |
path | A network shares a value with one defining source | Shared configuration |
Stream transport ​
A stream field describes the property of material leaving a component through a port. The associated flow determines transport direction. A connector containing stream fields has one flow field.
For a fluid port with stream h_outflow, instream(port.h_outflow) gives the incoming mixture seen at that port. It combines the contributions from the other connected ports according to stream semantics. This lets a component describe flow reversal using one interface.
Do not equate every connected h_outflow manually: outgoing fluid from different components can have different properties. Use connect and the stream operators to express mixing and transport. The Media and Fluids guide develops the library pattern, including the port's shared medium.
Shared network choices ​
A path field propagates a choice through a connected network. The network needs exactly one defining source for that choice. Use this mechanism when a library interface deliberately defines a value through network connectivity.
Paths propagate shared configuration; streams describe transported properties. The Media and Fluids example shows how a path shares one heat-capacity definition across a fluid network.
Build interfaces that compose ​
Expose the physical ports where material or energy crosses a subsystem boundary, and signal ports where another component supplies a command or receives a measurement. Give every physical port a documented sign convention. Choose boundary components that provide the reference, source, or sink needed to make a network well posed.
Port icons and positions are stored as metadata on the connector instances. They affect the graphical representation; connect defines the network. See Graphical Models and Metadata.