|
|
@@ -20,7 +20,6 @@ class SpringMassDamper(CBD):
|
|
|
│ │
|
|
|
└────────────────────────────────|-100y|────────────(-100)───────┘
|
|
|
"""
|
|
|
-
|
|
|
def __init__(self, block_name: str):
|
|
|
CBD.__init__(self, block_name, output_ports=["y"])
|
|
|
|
|
|
@@ -61,7 +60,7 @@ def run_experiment():
|
|
|
"""Use the defined Spring Mass Damper to run the experiment."""
|
|
|
smd = SpringMassDamper("SpringMassDamper")
|
|
|
sim = Simulator(smd)
|
|
|
- sim.setDeltaT(0.0000001)
|
|
|
+ sim.setDeltaT(0.0001)
|
|
|
sim.run(7.0)
|
|
|
|
|
|
time_values = []
|
|
|
@@ -70,8 +69,11 @@ def run_experiment():
|
|
|
time_values.append(signal.time)
|
|
|
y_values.append(signal.value)
|
|
|
fig, ax = plt.subplots(figsize=(5, 5), dpi=100)
|
|
|
- ax.plot(time_values, y_values, label="Position", color=[1.00, 0.55, 0.22])
|
|
|
+ ax.plot(time_values, y_values, label="Mass Position", color=[1.00, 0.55, 0.22])
|
|
|
ax.legend()
|
|
|
+ plt.xlabel("Time (s)", color="black")
|
|
|
+ plt.ylabel("Distance (m)", color="black")
|
|
|
+ plt.title("Spring Mass Damper System")
|
|
|
plt.show()
|
|
|
|
|
|
|