Using SPICE to Simulate Fluidic Systems

Complex multi-component fluidic systems can be simulated with free SPICE software, taking advantage of similarities between the equations that describe electrical circuits and fluid flows. This method is especially useful for dynamic systems that run with unsteady or oscillating flows, which are otherwise difficult to calculate. SPICE can be extended to work across multiple engineering domains, such as electromechanics, heat transfer, and acoustics. It provides a flexible tool for system engineers, product architects, and designers, allowing them to quickly evaluate design trade-offs and make estimates of component sizing.

Many engineers are familiar with SPICE as a tool for simulating electrical circuits. What is less well known is that it can also be used to simulate mechanical systems, with a little forethought and planning. This paper describes some ways to use SPICE to simulate the pressures and flows in a fluidic system.

The Fluidic Analogy

The thing that makes this possible is what is often called the “fluidic analogy,” which recognizes that electrical circuits and fluidic circuits have many things in common. They both consist of sources of energy, which drive a collection of components connected in series or parallel. The driving energy “flows” from one component to the next.

If you dig a little deeper, it turns out that the differential equations that describe these systems are essentially the same. Take for instance a capacitor, which stores charge in the form of electrical potential energy. The harder you “push” on a capacitor (higher voltage) the more potential energy it stores. The equation for this is:

where i is current, V is voltage and C is capacitance.

In the fluidic domain, an equivalent component is a cylindrical storage tank or reservoir, with a variable liquid height. As you pump harder into the bottom of the tank, you raise the fluid level and increase the stored potential energy. From Bernouli’s equation, we know that the pressure at the bottom of the tank is  P = ρgh.  Rearranging this, we get:

Where A is the area of the base of the tank, P is the pressure at the bottom of the tank, ρ is the fluid density, and g is acceleration due to gravity. Now we define a new quantity, fluidic capacitance:


With a little bit of equation wrangling, we eventually get to:


where Q is the flow rate. The important thing is that this equation looks exactly like the capacitor equation, except that we’ve used different variables: we’ve substituted pressure instead of voltage, and flow rate instead of current. That is what lies at the heart of the fluidic analogy.

Basic Fluidic Equations for SPICE

The good news is that in SPICE, you don’t need to ever think about the differential equations. All you need to know is the definition of fluidic capacitance (equation 3). You can insert a capacitor into a SPICE model, and give it a capacitance value that you calculated from equation 3. SPICE thinks that it’s an ordinary capacitor, but you know better: it’s actually a tank!

When you work through similar math for other fluidic components (pipes, pumps, orifices, etc.), you get the following:

Pay careful attention to the units. To keep things simple, I’ve chosen to define everything using basic SI units (m-kg-sec). The resulting values for R, I, and C are not terribly convenient (for typical real-world systems), but it’s the best way to guarantee that the units are all compatible.

A Note On Resistance

Resistance is the one place where the fluidic analogy isn’t perfect. In general,


but the devil is in the details. Fluidic resistance is not a nice, linear relationship like Ohm’s Law in the electrical world. We know from fluid dynamics that head loss is a complex phenomenon, involving friction factors, Reynolds numbers, etc. For simplicity here I have ignored most of that, and defined the fluidic resistance in terms of the Cv. The Cv is an empirical flow coefficient often quoted in datasheets for valves and orifices. This is a bit of simplification, but should be perfectly fine for most system modeling work.

For long pipes, a reasonable approximation is:


(from Bernouli’s equation)(7)

(Blasius fit to Moody chart)

A full discussion of fluidic resistance is beyond the scope of this paper, so take the equations here only as an approximate starting point.

Example 1 – Tank Filling Problem

This is a simple system, with a pump feeding water into a storage tank and an open valve on the tank outlet. The flow from the pump is 1.26×10-3 m3/s (75.7 LPM). The tank has a diameter of 1.0 m, and is assumed to be tall enough to prevent overflowing. The valve has a Cv of 10. We want to determine the pressure in the bottom of the tank after the level reaches steady state.

In SPICE the model looks like this:

In this example, the pump is modeled as an ideal DC current source, with the current equal to the pump flow rate. The tank is modeled as a capacitor, and the outlet valve is a resistor. Every circuit in SPICE needs to be grounded somewhere. When modeling fluidics, ground is equivalent to ambient pressure, so in this example we tie both the pump inlet and the valve outlet to ground. The tank is open to the atmosphere, so one end of the capacitor is also tied to ground.

A quick run of the SPICE simulation shows that after 3 hours, the pressure at the bottom of the tank stabilizes at around 0.28 bar, indicating that the liquid height is around 2.8 m. The y-axis in the plot below has been scaled to show the pressure in bars, rather than Pascals.


Example 2 – Two Pumps and an Elastic Hose

Simple steady-state simulations like Example 1 are relatively easy to do on paper or in a spreadsheet. Where SPICE really shines is in cases where the flow is unsteady. In this example, there are two pumps: the main pump provides a steady flow, while the metering pump injects periodic pulses of flow into the main line. Downstream of these pumps is a long length of soft rubber hose. Because the hose is elastic, it acts like a capacitor, storing potential energy as the pressure rises and the tube inflates. The tube also has an inertance term, to account for the momentum of the fluid in the hose. This capacitance and inertance add a dynamic element to the system, with the possibility of oscillation, resonance, etc.

The SPICE model:

The main pump is modeled more realistically than it was in example 1. Here, instead of assuming a constant flow rate, we use what SPICE calls an arbitrary current source, with tabulated flow and pressure data taken from the pump datasheet. The unrestricted flow is 3.8 LPM, and the deadhead pressure is 0.068 bar.

The metering pump is also a current source, set to provide a periodic square wave, where each pulse is one dose from the pump. The flow rate during each dose is 3.8 LPM, the dose lasts for 1 second, and there is one pulse every 60 seconds.

The hose in this example is 10 m long, with an inner diameter of 10mm, and an elastic modulus of 1.0 MPa. For simplicity in this example, the pressure drop through the hose is assumed to be negligible. The valve at the end of the hose has a Cv of 1.0.

The simulation shows that the peak flow rate (during the metering pulses) is 8.06 LPM, with some instability in the flow at the start and end of each pulse. This is much more detailed information than you could get from a paper/spreadsheet calculations.


The two examples here show just a hint of what is possible to model in SPICE. Some possible extensions to these models:

  • Add multiple pipe branches, with tees, wyes, elbows, valves, distribution headers, etc.
  • Add timing info for the valves, to open/close them in a particular sequence.
  • Add an accumulator to absorb pressure spikes.
  • Simulate the pump motor by adding electrical components, based on the motor datasheet parameters.
  • Add elements to simulate a gearbox between the motor and the pump.
  • Predict cavitation by monitoring pump suction pressure.

SPICE contains a number of useful analysis commands, allowing you to probe the data that it generates:

  • Voltage and current (pressure and flow) at any point
  • Max/Min
  • Integral/Derivative
  • Average
  • RMS
  • Peak-to-peak
  • FFT
  • Export waveform

Beyond fluidics, SPICE can be used to simulate almost any mechanical system that can be approximated with a 1-D lumped model, such as:

  • Motors and electromechanical devices
  • Spring-mass-damper systems
  • Heat transfer (V=temperature, I=heat flow)
  • Acoustics
  • Any combination of these

These models are, naturally, just approximations, and they gloss over some of the subtle engineering details. Nonetheless, SPICE provides a surprisingly useful tool for high-level system modeling. It’s relatively easy to learn (compared to other system modeling tools) and the software is free!

SPICE Software

SPICE has been available for a few decades, and it is stable and mature. There are several popular implementations, both open-source and proprietary. One of the more popular versions is LTSpice, freely available from Linear Technology. It has a simple graphical interface, built-in data plotting features, and reasonably useful help files. LTSpice is widely used in the engineering community, so additional help is readily available online.