PySpice icon indicating copy to clipboard operation
PySpice copied to clipboard

Is it possible to save the analysis object to disk?

Open danieljfarrell opened this issue 1 year ago • 1 comments

Environment (OS, Python version, PySpice version, simulator)

macOS 13.5, Python 3.12.2, PySpice 1.5, ngspice-42

I am simulating very large circuits that can take many minutes to solve.

For this reason I would like to be able to save the analysis object, so I do not have to recalculate it.

How can I save the analysis object to disk?

Pickle does not work

cir = Circuit(net)
simulator = cir.simulator(temperature=25, nominal_temperature=25)
result = simulator.dc(Vin=slice(-1, 2, 0.01))

import pickle
with open("result.obj", "wb") as f:
    pickle.dump(result, f)  # <-- this line crashes

The pickle fails,

Traceback (most recent call last):
  File "<snip>.py", line <snip>, in <module>
    pickle.dump(result, f)
TypeError: cannot pickle '_cffi_backend.__CDataOwn' object

Is there another way to export this object and save the data that you can recommend?

danieljfarrell avatar Jul 09 '24 11:07 danieljfarrell

Yes, devel version analysis is pickable.

tapegoji avatar Mar 05 '25 01:03 tapegoji