No-Flow Component — Voltage Sensor

The following file, `voltage_sensor.ssc`, implements a component called `voltage_sensor`. An ideal voltage sensor has a very large resistance, so there is no current flow through the sensor. Therefore, declaring a Through variable, as well as writing branches and equation statements for it, is unnecessary.

The declaration section of the component contains:

• One output port, `V`, to output the measured voltage as a physical signal

• Two electrical nodes, `p` and `n` (for + and – terminals, respectively)

• An Across variable, voltage `v1`, to be connected to the electrical domain later in the file

Note that a Through variable (current ) is not declared, and there is no `branches` section.

In the equation section, the first equation, `v1 == p.v - n.v`, establishes the relationship between the component Across variable, voltage `v1`, and the component nodes (and therefore the domain Across variable at these nodes). It defines the voltage across the sensor as the difference between the node voltages.

The second equation defines the voltage sensor action: `V == v1`, that is, output voltage equals the voltage across the sensor nodes.

```component voltage_sensor % Voltage Sensor % The block represents an ideal voltage sensor. There is no current % flowing through the component, therefore it is unnecessary to % declare a Through variable (i1), use a branches section, or % create an equation statement for current (such as i1 == 0). % % Connection V is a physical signal port that outputs voltage value. outputs V = { 0.0, 'V' }; % V:bottom end nodes p = foundation.electrical.electrical; % +:top n = foundation.electrical.electrical; % -:bottom end variables v1 = { 0, 'V' }; end equations v1 == p.v - n.v; V == v1; end end ```