Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyspice.simulator.noise not working as expected #375

Open
MaxRonce opened this issue Jun 19, 2024 Discussed in #374 · 0 comments
Open

pyspice.simulator.noise not working as expected #375

MaxRonce opened this issue Jun 19, 2024 Discussed in #374 · 0 comments

Comments

@MaxRonce
Copy link

MaxRonce commented Jun 19, 2024

Discussed in #374

Originally posted by MaxRonce June 19, 2024
Hello, could I have an example of how to use the simulation.noise function with PySpice? All the online documentation I found isn't very helpful, and I couldn't figure out how to use this function properly.

image

I need to simulate a simple RLC circuit (see below).

image

I want to perform a noise analysis on this circuit. I've tried to use the transient analysis and measure impedance using PySpice simulation: everything works well.

However, when I try to use the .noise simulation, I can't get it to work properly.

    f_start = 1
    f_stop = 1000000
    circuit = Circuit(' Imp JUICE')

    V1 = circuit.SinusoidalVoltageSource('V1', 'N1', circuit.gnd, amplitude=1 @ u_V, frequency=1 @ u_kHz)
    circuit.R('1', 'N1', 'N001', 550 @ u_Ω)
    circuit.C('1', 'N2', 'N1', 150 @ u_pF)
    circuit.L('1', 'N2', 'N001', 12 @ u_H)
    circuit.R('2', 'N2', circuit.gnd, 1 @ u_kΩ)

    temperature = 25
    f_start = 1
    f_stop = 1000000


    simulator = circuit.simulator(temperature=temperature, nominal_temperature=25)
    analysis = simulator.noise(
        output_node='N1', 
        ref_node='N2', 
        src='V1',  
        points=100,
        start_frequency=f_start @u_Hz,  
        stop_frequency=f_stop @u_Hz,  
        variation='dec'
    )

error

Traceback (most recent call last):
  File "XX\PLASMAG\src\model\strategies\strategy_lib\SPICE.py", line 384, in <module>
    analysis = simulator.noise(
  File "XX\PLASMAG\lib\site-packages\PySpice\Spice\Simulation.py", line 1176, in noise
    return self._run('noise', *args, **kwargs)
  File "XX\lib\site-packages\PySpice\Spice\NgSpice\Simulation.py", line 118, in _run
    self._ngspice_shared.run()
  File "XX\lib\site-packages\PySpice\Spice\NgSpice\Shared.py", line 1168, in run
    self.exec_command(command)
  File "XX\lib\site-packages\PySpice\Spice\NgSpice\Shared.py", line 842, in exec_command
    raise NgSpiceCommandError("Command '{}' failed".format(command))
PySpice.Spice.NgSpice.Shared.NgSpiceCommandError: Command 'run' failed

I ran the same simulation in the LTSpice software after recreating the RLC circuit there, and the noise analysis works.

Could anyone help me fix this or provide a hint about how to use this function? I spent a lot of time without getting proper results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant