PySpice icon indicating copy to clipboard operation
PySpice copied to clipboard

Implementation of parameters (.param)

Open HGrabas opened this issue 7 years ago • 2 comments

Preliminary information:

In a similar fashion than circuit element manipulation one would expect to access the .param values of a netlist using the dictionary:

From netlist-manipulation:

We can get back an element of a circuit using its name, either as a class attribute or using the dictionary interface: C1 = circuit.C1 C1 = circuit['C1'] and modify it

C1.capacitance = 10@u_F

Defining circuit parameters .param in ngspice is done in the following way in PySpice:

circuit.parameter('F=1','F=1') ##TODO report bad implementation 
circuit.parameter('FC={SQRT(F)}','F={SQRT(F)}') ##TODO report bad implementation 

There is also no clear way to access and modify the .param similar to C1.capacitance = 10@u_F

Expected Behaviour

circuit.parameter('F','F=2') ##TODO report bad implementation 
print(circuit)

.param F=2

Actual Behaviour

  • The key of the dictionary is used to set the .param field in ngspice and not the value
circuit.parameter('F=1','F=2') ##TODO report bad implementation
circuit.parameter('FC={SQRT(F)}','F={SQRT(F)}') ##TODO report bad implementation 
print("Printing circuit parameters")
print(circuit._parameters)
print(circuit)

Returns:

Printing circuit parameters {'F=1': 'F=2', 'FC={SQRT(F)}': 'F={SQRT(F)}'} .param F=1

Steps to reproduce the behaviour

circuit.parameter('F=1','F=2') ##TODO report bad implementation 
print(circuit._parameters)
print(circuit)

In the ngSpice netlist:

.param F=1

-> Here you'd expect F=2

HGrabas avatar Jul 20 '18 21:07 HGrabas

Would be interesting to list uses cases for parameters versus a Pythonic parametrisation.

FabriceSalvaire avatar Jul 29 '18 14:07 FabriceSalvaire

Good point - I am not sure that there are any. Only reporting a possible enhancement (as you rightfully labeled it) of the way .param are generated in PySpice. Indeed .param can be handled in a much nicer way in Python rather than within SPICE.

HGrabas avatar Aug 01 '18 00:08 HGrabas