Kaynağa Gözat

Improve graph image

Arkadiusz Ryś 2 yıl önce
ebeveyn
işleme
cbdbc76d45
3 değiştirilmiş dosya ile 7 ekleme ve 5 silme
  1. 2 2
      README.md
  2. 5 3
      damper/system.py
  3. BIN
      docs/trace.png

+ 2 - 2
README.md

@@ -1,10 +1,10 @@
 # Spring Mass Damper
 
-A causal block diagram representation of a spring mass damper.
+A causal block diagram representation of a spring mass damper system.
 Simulated using [a causal block simulator](https://git.rys.one/dtdesign/cbd).
 
 The formula we follow to achieve this is: `0 = 100 - 2y' - 100y - y"`.
-Here the friction coefficient is `0.02 Ns/m` and the spring constant is `1 N/m` with the block weighing in at `0.01 kg`.
+Here, the friction coefficient is `0.02 Ns/m` and the spring constant is `1 N/m` with the block weighing in at `0.01 kg`.
 
 The simulated position (distance) of the spring is described by the following graph.
 ![execution-trace](docs/trace.png)

+ 5 - 3
damper/system.py

@@ -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()
 
 

BIN
docs/trace.png