¿ªÔÆÌåÓý

Re: Multiple instances of "C:U2:spark"


 

¿ªÔÆÌåÓý

On 03/07/2023 14:30, Richard Andrews via groups.io wrote:
I uploaded a new file. Now I get that ltspice thinks B is a node. Hello Tony Casey, I'll try your first option later. Thank you.
This is what you uploaded:

.subckt sparkgap p n

* Parameters
* d: Gap distance in meters
* aa: Gap area in sqr meters
* p: Gas pressure in Pascals

* Model constants
?.param A = 5.19e-11
?.param B = 23.8
?.param C = 11.6

* Spark gap voltage
Vspark = (B * p * d) / log(A * p * d) - log(log(1+(1/1.2)))-C

* Capacitance of gap
* Spark gap resistance
Cspark p n 8.85e-12 * aa / d
Rspark p n 1e12 / Vspark

.ends

What about Vspark? That needs to be defined as a parameter, too. As it is, LTspice think Vspark is a voltage source, so naturally is assuming the next two strings are the nodenames that it is connected to.

Only circuit elements can begin without a dot. What a circuit element is assumed to be is defined (normally) by its first letter: "R" for resistor, "C" for capacitor and "V" for voltage source", and so on. Some initial letters are also invalid: no element name can begin with "N" or "P" - they are not defined.

Everything else is a directive and must start with a dot.

It is also normal to begin a .subckt definition with a comment, starting with "*". Originally, SPICE assumed the first line was always a comment, but I'm not sure how strictly that is enforced, now. LTspice is quite forgiving of certain things.

Additionally, where are "d", "aa" and "p" defined? Are you going to try to pass them into the .subckt as arguments? If so, they still need to be defined as parameters, too, even if the default value is overwritten by an argument.

--
Regards,
Tony

Join [email protected] to automatically receive all group messages.