def __init__(self, k=50.0, m=1.0, g=9.8, **kw): self.k = k self.m = m self.g = g self.dim = 2 self.z = map(S, ['z0', 'z1']) self.p = map(S, ['p0', 'p1']) self.q = map(S, ['q0', 'q1']) self.x = map(S, ['x0', 'x1', 'x2', 'x3']) self.u = map(S, ['u0', 'u1']) self.Mq = np.eye(self.dim) * self.m self.Mqi = np.eye(self.dim) / self.m self.Vq = -self.m * self.g * self.q[1] # create Ohm and Psi self._Ohm = np.array([self.z[0], self.z[1] + sym.sin(self.z[0])]) self._Psi = np.array([self.q[0], self.q[1] - sym.sin(self.q[0])]) #self.controller = lambda t, x: [0, 0] super(SinFloor2D, self).__init__(si=1)
def __init__(self, k=50.0, m=1.0, g=9.8, **kw): self.k = k self.dim = 2 self.z = map(S, ['z0', 'z1']) self.p = map(S, ['p0', 'p1']) self.q = map(S, ['q0', 'q1']) self.x = map(S, ['x0', 'x1', 'x2', 'x3']) self.u = map(S, ['u0', 'u1']) self.Mq = np.eye(self.dim) * m self.Mqi = np.eye(self.dim) / m self.Vq = -m * g * self.q[1] # create Ohm and Psi self._Ohm = self.z self._Psi = self.q super(FlatFloor2D, self).__init__(si=1)
def _delf(self, t, xval, uval): # calculates the jump term assuming the field switches # between fplus and fminus at (t, x) params = np.concatenate(([t], xval, uval)) fp = self._fplus.func(*params) fm = self._fmins.func(*params) dphi = self.dphi(xval) # this assumes x = [z, zdot] M = tn.eval(self.Mz, self.z, xval[:self.dim]) M = scipy.linalg.block_diag(M, np.eye(self.dim)) #dphi = matmult(M, dphi) out = -np.outer(fp-fm, dphi)/np.abs(np.inner(fp, dphi)) #Tracer()() #out = np.zeros((2*self.dim, 2*self.dim)) #for i in range(self.dim): # out[self.si, i] = -M[self.si, i] return out