Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rimjhimittal committed Jun 18, 2024
1 parent 1e6e643 commit c29534f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
49 changes: 30 additions & 19 deletions examples/MDF/switched_rlc.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,36 @@ def run_simulation(mod_graph, duration=2, dt=0.001):
V_values.append(V)
t += dt

fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 10))

ax1.plot(times, i_L_values, label='Inductor Current (i_L)')
ax1.plot(times, i_R_values, label='Resistor Current (i_R)')
ax1.plot(times, i_C_values, label='Capacitor Current (i_C)')
ax1.set_xlabel('Time (s)')
ax1.set_ylabel('Current (A)')
ax1.set_title('Currents in RLC Circuit')
ax1.legend()

ax2.plot(times, V_values, label='Response Voltage (V)', color='orange')
ax2.plot(times, Vs_values, label='Source Voltage (Vs)', color='green')
ax2.set_xlabel('Time (s)')
ax2.set_ylabel('Voltage (V)')
ax2.set_title('Voltage in RLC Circuit')
ax2.legend()

plt.tight_layout()
plt.savefig("switched_rlc_plot.png")
# fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 10))

# ax1.plot(times, i_L_values, label='Inductor Current (i_L)')
# ax1.plot(times, i_R_values, label='Resistor Current (i_R)')
# ax1.plot(times, i_C_values, label='Capacitor Current (i_C)')
# ax1.set_xlabel('Time (s)')
# ax1.set_ylabel('Current (A)')
# ax1.set_title('Currents in RLC Circuit')
# ax1.legend()

# ax2.plot(times, V_values, label='Response Voltage (V)', color='orange')
# ax2.plot(times, Vs_values, label='Source Voltage (Vs)', color='green')
# ax2.set_xlabel('Time (s)')
# ax2.set_ylabel('Voltage (V)')
# ax2.set_title('Voltage in RLC Circuit')
# ax2.legend()

# plt.tight_layout()
# plt.savefig("switched_rlc_plot.png")
# plt.show()

plt.figure(figsize=(10, 5))
plt.plot(times, i_L_values, label='Inductor Current (i_L)')
plt.plot(times, i_R_values, label='Resistor Current (i_R)')
plt.plot(times, i_C_values, label='Capacitor Current (i_C)')
plt.plot(times, V_values, label='Voltage (V)')
plt.xlabel('Time (s)')
plt.ylabel('Values')
plt.title('Switched RLC Circuit Simulation Results')
plt.legend()
plt.show()

return times, i_L_values, i_R_values, i_C_values, V_values
Expand Down
2 changes: 1 addition & 1 deletion test_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ python states.py -run -nogui
python abc_conditions.py -run
python params_funcs.py -run
python newton.py -run
python switched_rlc_circuit.py -run
python switched_rlc.py -run

## Test exporting to NeuroML

Expand Down

0 comments on commit c29534f

Please sign in to comment.