aesim-tech / simba-project

Roadmap & issue tracking
7 stars 0 forks source link

Improve Python Module Array and Matrix Interoperability #325

Closed manu-aesim closed 1 year ago

manu-aesim commented 1 year ago

Starting with version 23.08, reading and writing parameters for double arrays and double matrices has been simplified.

When reading an array or a matrix, a python list (1D or 2D) is returned:


from aesim.simba import DesignExamples
design = DesignExamples.Interleaved_buck()
L1 = design.Circuit.GetDeviceByName("L1")

L1.Inductance = "[100u -80u ; -80u 100u]" # It is possible to set the value with a string 
l = L1.Inductance; # Get Python 2D Array
print("l(1): " + str(l))

l[1][0] = -90E-6;
l[0][1] = -90E-6;
L1.Inductance = l; # Second option to set matrix parameter (python array)
print("l(2): " + str(L1.Inductance))

L1.Inductance =  [[100E-6, -90E-6], [-90E-6, 100E-6]] # That also works
print("l(3): " + str(L1.Inductance)) 

L1.Inductance[0][0] = 666 # WARNING! This will NOT work because this will not change the L1.Inductance parameter
print("l(4): " + str(L1.Inductance)) 

Output:

l(1): [[9.999999999999999e-05, -7.999999999999999e-05], [-7.999999999999999e-05, 9.999999999999999e-05]]
l(2): [[9.999999999999999e-05, -9e-05], [-9e-05, 9.999999999999999e-05]]
l(3): [[0.0001, -9e-05], [-9e-05, 0.0001]]
l(4): [[0.0001, -9e-05], [-9e-05, 0.0001]]