It would be very advantageous to be able to set the lower and upper voltage limits in vcvs and ccvs and the lower and upper current limits in vccs and cccs. Could this be implemented in ngspice?
The vcvs and ccvs are very efficient (i.e. fast) basic devices that can be solved in a single timestep. Adding limits to them removes their best features.
Why not add limits to a behavioral source, or use a table source?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, i used behavioural sources with a limit function but it would be much more user-friendly if it already can be set in the vcvs etc. If there would be too much performance degradation, could you please introduce a vcvs_limit function e.g. which uses the vcvs and limits the outputs? Then both would work and if performance is not such important the vcvs with limit function can be used :)
In addition with a dedicated xschem symbol this would be quite user-friendly, I almost always needed the limit function (saturation behaviour) during circuit design when using a vcvs.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The whole thing may be put into a subcircuit with parameters, see below. This is the typical model to be attached to a symbol in the KiCad world. Maybe XSCHEM is similar. If called as an X line, parameters may be set by the user. Another advantage is that this model smoothes the output when reaching the limit. The derivative is continuous, supporting convergence. Current control or current output may be achieved by replacing %vd by %id at the input or output respectively.
The vcvs and ccvs are very efficient (i.e. fast) basic devices that can be solved in a single timestep. Adding limits to them removes their best features.
Why not add limits to a behavioral source, or use a table source?
Yes, i used behavioural sources with a limit function but it would be much more user-friendly if it already can be set in the vcvs etc. If there would be too much performance degradation, could you please introduce a vcvs_limit function e.g. which uses the vcvs and limits the outputs? Then both would work and if performance is not such important the vcvs with limit function can be used :)
In addition with a dedicated xschem symbol this would be quite user-friendly, I almost always needed the limit function (saturation behaviour) during circuit design when using a vcvs.
What about using an analog code model as described in chapter 8.2.5 Limiter of the ngspice manual?
Last edit: Holger Vogt 2025-07-11
A vcvs with limits is described as
The whole thing may be put into a subcircuit with parameters, see below. This is the typical model to be attached to a symbol in the KiCad world. Maybe XSCHEM is similar. If called as an X line, parameters may be set by the user. Another advantage is that this model smoothes the output when reaching the limit. The derivative is continuous, supporting convergence. Current control or current output may be achieved by replacing %vd by %id at the input or output respectively.
Yes, that would also be an option. Thank you very much! I will try to create an xschem symbol for this.