Solenoid modelling with basic blocks and physical modelling blocks
This example shows a solenoid with a return spring. The solenoid is modelled as an inductance whose value L depends on the piston position x. The inverse EMF for a time-varying inductance is defined as:
Since L depends on x:
can be obtained using data from the manufacturer and using the ratio:
Then can be integrated to get L as a function of x.
In the model, equation (2) is recalculated to solve for i and then implemented using physical blocks. The controlled current source then limits the magnitude of the current by equating it to i.
Schematic of the model:

Simulation results:
Values of solenoid current over time, A:
.png)
Values of the force generated by the solenoid over time, N:
.png)