fn run(inout self) raises -> None:
with open(self.output_path, "w") as f:
var out: String = "location,velocity,acceleration\n"
for _ in range(1, self.numsteps + 1):
self.velocity = self.velocity + self.acceleration * self.deltaT / 2
self.location = self.location + self.velocity * self.deltaT
self.acceleration = -1 * self.location
out += str(self.location) + "," + str(self.velocity) + "," + str(self.acceleration) + "\n"
f.write(out)
fn run(inout self) raises -> None:
with open(self.output_path, "w") as f:
var out: String = "location,velocity,acceleration\n"
for _ in range(1, self.numsteps + 1):
self.velocity = self.velocity + self.acceleration * self.deltaT / 2
self.location = self.location + self.velocity * self.deltaT
self.acceleration = -1 * self.location
out += str(self.location) + "," + str(self.velocity) + "," + str(self.acceleration) + "\n"
f.write(out)