Skip to content
Get started

3. Algebraic relations and networks

Many models are networks of simultaneous statements rather than recipes that calculate one variable after another. Conservation at a junction, compatibility between connected parts, and a constitutive law can all constrain the same unknowns. Calling one variable an “input” too early can hide that structure.

Eqiora writes each statement as a residual equal to zero. An equation such as a+b=sa+b=s therefore has the residual a+b−sa+b-s. The ordering of the symbols does not assign a computational direction.

After this chapter, you should be able to:

  • distinguish unknown quantities, prescribed parameters, and relations;
  • count unknowns and independent scalar relations in a small model;
  • separate conservation from the law that closes a network;
  • compile an algebraic .eqi model without selecting a solver; and
  • identify underdetermined, overconstrained, and inconsistent structures.

What fixes the temperature between two layers?

Section titled “What fixes the temperature between two layers?”

Imagine two thermal resistances in series between reservoirs at ThT_h and TcT_c. The unknown interface temperature is TmT_m. Each resistance is a lumped relation Q˙=ΔT/R\dot Q=\Delta T/R, where RR has units kelvins per watt. Assume no energy accumulates at the interface and no heat escapes sideways.

text
T_h ── [ R₁ ] ── T_m ── [ R₂ ] ── T_c
Q̇₁ → Q̇₂ →

Conceptual network. Both arrows point from the hot reservoir toward the cold reservoir; steady interface balance requires equal signed powers.

There are three unknowns: TmT_m, Q˙1\dot Q_1, and Q˙2\dot Q_2. Two constitutive relations and one balance close the problem:

Q˙1=Th−TmR1,Q˙2=Tm−TcR2,Q˙1−Q˙2=0.\dot Q_1=\frac{T_h-T_m}{R_1},\qquad \dot Q_2=\frac{T_m-T_c}{R_2},\qquad \dot Q_1-\dot Q_2=0.

Eliminating the powers gives

Tm=R2Th+R1TcR1+R2,Q˙=Th−TcR1+R2.T_m=\frac{R_2T_h+R_1T_c}{R_1+R_2},\qquad \dot Q=\frac{T_h-T_c}{R_1+R_2}.

For Th=340 KT_h=340\,\mathrm K, Tc=300 KT_c=300\,\mathrm K, R1=1 K/WR_1=1\,\mathrm{K/W}, and R2=3 K/WR_2=3\,\mathrm{K/W}, predict Q˙=10 W\dot Q=10\,\mathrm W and Tm=330 KT_m=330\,\mathrm K. The larger resistance takes the larger temperature drop. The heat-transfer path derives a slab’s resistance from a spatial field rather than assuming it.

The abstract splitter below keeps the same distinction between balance and closure while making the source small enough to inspect at once.

Let a prescribed amount ss split into two unknown branch amounts aa and bb. Conservation provides one relation,

a+b−s=0.a+b-s=0.

That relation alone cannot determine both branches. For a symmetric splitter, the constitutive or design assumption a−b=0a-b=0 supplies the second relation. Substitution gives a=b=s/2a=b=s/2. The model stores the two relations, not the order in which you eliminated variables to solve them.

Save this as split.eqi:

split.eqi
// Two unknown branch amounts closed by conservation and an equal-split law.
model split() {
parameter supplied: 1 = 1;
variable branch_a: 1;
variable branch_b: 1;
relation conservation {
branch_a + branch_b - supplied = 0;
}
relation equal_split {
branch_a - branch_b = 0;
}
}

Use the environment from Get started to check your file:

Terminal windowconsole
$ uv run python -c "import eqiora; eqiora.compile(path='split.eqi')"

View the model source.

Compilation checks the source and typed expressions. It does not execute this algebraic model or prove that the two residuals are globally independent.

For this example:

Item Count Role
Prescribed parameters 1 supplied is known for one model instance.
Scalar unknowns 2 branch_a and branch_b must be determined.
Scalar relations 2 conservation and equal split close this particular structure.

Matching counts are a useful first check, not a guarantee. Two copies of the conservation relation would still leave the split undetermined. A third relation demanding branch_a = supplied would contradict equal split when supplied is nonzero. Independence and consistency depend on relation content, not names or counts.

In a physical network, a component usually supplies its constitutive relation, while a connection supplies compatibility or conservation across ports. The model is therefore acausal: the assembled relations, not the order in which connections are written, determine which quantities must be solved together.

Once the equations are understood, import the parts

Section titled “Once the equations are understood, import the parts”

The electrical counterpart makes reusable components concrete. For two resistors in parallel across ideal voltage VV, equal voltage across both branches is compatibility, Ij=V/RjI_j=V/R_j is the component law, and Is=I1+I2I_s=I_1+I_2 is junction conservation. These roles follow the circuit reasoning in OpenStax, section 10.3.

For an illustrative V=6 VV=6\,\mathrm V, R1=2 ΩR_1=2\,\Omega, and R2=4 ΩR_2=4\,\Omega, the hand prediction is I1=3 AI_1=3\,\mathrm A, I2=1.5 AI_2=1.5\,\mathrm A, and total current 4.5 A4.5\,\mathrm A. The supplied power is 27 W27\,\mathrm W, equal to 18+9 W18+9\,\mathrm W dissipated in the two resistors. This second check asks about energy as well as charge.

Here is the actual composition. It imports the resistor, source, and ground definitions, then states which ports connect:

Eqiora.Electrical.Circuits: ParallelDc
import Eqiora.Electrical.Basic.basic as basic;
public component ParallelDc(
parameter supply_voltage: kg * m ^ 2 / (s ^ 3 * A),
parameter resistance_two: kg * m ^ 2 / (s ^ 3 * A ^ 2),
parameter resistance_four: kg * m ^ 2 / (s ^ 3 * A ^ 2)
) {
instance source: basic.IdealVoltageSource(voltage = supply_voltage);
instance resistor_two: basic.Resistor(resistance = resistance_two);
instance resistor_four: basic.Resistor(resistance = resistance_four);
instance ground: basic.Ground();
connect source.positive, resistor_two.positive, resistor_four.positive;
connect source.negative, resistor_two.negative, resistor_four.negative, ground.terminal;
}

Open the basic component definitions and locate the resistor’s law. Then find the connection statements above: the library supplies the material relation, and the circuit supplies its connections. The import saves retyping because its equations already express the assumptions we derived. The circuits path develops this into a runnable circuit investigation.

Interpret the two residuals against the hand solution a=b=s/2a=b=s/2. Each must vanish separately: their sum could hide a positive error in one relation and a negative error in the other. The compiler check prepares the source; substitution is what establishes the solution here.

Deliberate failure: remove the closing relation

Section titled “Deliberate failure: remove the closing relation”

Delete equal_split while retaining conservation. The source remains readable and dimensionally consistent, so the current compile check need not diagnose the missing physical assumption. By hand, one equation constrains two unknowns: every pair satisfying a+b=sa+b=s is possible. The repair is to state a justified second relation, not to choose an arbitrary solver default.

Successful compilation does not prove that a model is closed or physically meaningful.

  1. For s=1s=1, list three distinct pairs (a,b)(a,b) that satisfy conservation when equal_split is absent.
  2. Replace equal split with a=2ba=2b. Derive both branch amounts without changing the conservation relation.
  3. Add the relation a=sa=s to the original symmetric model. For which value of ss are all three relations consistent?
  4. Give one circuit or flow-network example in which a connection owns conservation and a component owns a constitutive law. Identify every unknown and prescribed parameter.

Exercise 1 has the family (a,b)=(α,1−α)(a,b)=(\alpha,1-\alpha); nonnegative branch amounts would additionally require 0≤α≤10\le\alpha\le1. Exercise 2 gives a=2s/3a=2s/3 and b=s/3b=s/3. In exercise 3, consistency requires s=0s=0.

For a further modeling experiment, give the thermal interface a finite heat capacity CmC_m. Conservation becomes CmT˙m=Q˙1−Q˙2C_m\dot T_m=\dot Q_1-\dot Q_2. The algebraic relations for the resistances stay unchanged, but you now need an initial temperature. Explain why steady state recovers the result above.

Previous: Quantities, dimensions, and units · Back to the series map · Next: Ordinary differential equations