c4dynamics.states.state.state.store#
- state.store(t=-1)[source]#
Stores the current state.
The current state is defined by the vector of variables as given by
state.X
.store()
is used to store the instantaneous state variables.- Parameters:
t (float or int, optional) – Time stamp for the stored state.
Note
1. Time t is an optional parameter with a default value of \(t = -1\). The time is always appended at the head of the array to store. However, if t is not given, default \(t = -1\) is stored instead.
2. The method
store()
goes together with the methodsdata()
andtimestate()
as input and outputs.3.
store()
only stores state variables (those constructstate.X
). For other parameters, usestoreparams()
.Examples
>>> s = c4d.state(x = 1, y = 0, z = 0) >>> s.store()
Store with time stamp:
>>> s = c4d.state(x = 1, y = 0, z = 0) >>> s.store(t = 0.5)
Store in a for-loop:
>>> s = c4d.state(x = 1, y = 0, z = 0) >>> for t in np.linspace(0, 1, 3): ... s.X = np.random.rand(3) ... s.store(t)
Usage of
store()
inside a program with adatapoint
from thestates library
:>>> t = 0 >>> dt = 1e-3 >>> h0 = 100 >>> dp = c4d.datapoint(z = h0) >>> while dp.z >= 0: ... dp.inteqm([0, 0, -c4d.g_ms2], dt) ... t += dt ... dp.store(t) >>> for z in dp.data('z'): ... print(z) 99.9999950 99.9999803 99.9999558 ... 0.00033469 -0.0439570