Esempio n. 1
0
def cost_m1_only(theta):
    M = np.eye(3)
    M[0, 0] = theta[0]
    lmm = s.LMM_sys(M, C, K, f, X0, Xd0, t)
    sol = lmm.solve_de("RK")

    return np.linalg.norm(sol - measured)
Esempio n. 2
0
def optiminum_plot(theta):
    M = np.eye(3)
    M[0, 0] = theta[0]
    X0 = np.array([theta[1:4]]).T
    Xd0 = np.array([theta[4:]]).T

    lmm = s.LMM_sys(M, C, K, f, X0, Xd0, t)
    sol = lmm.solve_de("RK")
    return sol
Esempio n. 3
0
def cost_m1_init_cond_meas1_state(theta):
    M = np.eye(3)
    M[0, 0] = theta[0]
    X0 = np.array([theta[1:4]]).T
    Xd0 = np.array([theta[4:]]).T

    lmm = s.LMM_sys(M, C, K, f, X0, Xd0, t)
    sol = lmm.solve_de("RK")
    return np.linalg.norm(sol[:, -3] - measured[:, -3])
Esempio n. 4
0
def cost_m1_init_cond_meas1_state(theta):
    def K(t):
        freq = 10
        return Km + np.array([[1, -1, 0], [-1, 0, 0], [
            0, 0, 1
        ]]) * theta[0] * 0.5 * (1 + sig.square(t * 2 * np.pi * freq))

    X0 = np.array([theta[1:4]]).T
    Xd0 = np.array([theta[4:]]).T

    lmm = s.LMM_sys(M, C, K, f, X0, Xd0, t)
    sol = lmm.solve_de("RK")
    return np.linalg.norm(sol[:, -3] - measured[:, -3])
Esempio n. 5
0
def optiminum_plot(theta):
    M = np.eye(3)
    M[0, 0] = 1.5
    X0 = np.array([theta[1:4]]).T
    Xd0 = np.array([theta[4:]]).T

    f = np.zeros((3, 1))
    f[0, 0] = 100

    def K(t):
        freq = 10
        return Km + np.array([[1, -1, 0], [-1, 0, 0], [
            0, 0, 1
        ]]) * theta[0] * 0.5 * (1 + sig.square(t * 2 * np.pi * freq))

    lmm = s.LMM_sys(M, C, K, f, X0, Xd0, t)
    sol = lmm.solve_de("RK")
    return sol
Esempio n. 6
0
C = np.array([[0.55, -0.2, 0], [-0.2, 0.55, -0.2], [0, -0.2, 0.35]])

M = np.eye(3)
M[0, 0] = 1.5

f = np.zeros((3, 1))
f[0, 0] = 100

X0 = np.zeros((3, 1))
Xd0 = np.ones((3, 1)) * 0.8

t = np.linspace(0, 10, 10000)

# Generate actual and measured response
lmm = s.LMM_sys(M, C, K, f, X0, Xd0, t)
true = lmm.solve_de("RK")

measured = np.random.normal(true, 0.16)


def cost_m1_init_cond_meas1_state(theta):
    def K(t):
        freq = 10
        return Km + np.array([[1, -1, 0], [-1, 0, 0], [
            0, 0, 1
        ]]) * theta[0] * 0.5 * (1 + sig.square(t * 2 * np.pi * freq))

    X0 = np.array([theta[1:4]]).T
    Xd0 = np.array([theta[4:]]).T
    -------
    freq: Frequency range
    magnitude:
    phase:
    """

    d = data
    length = len(d)
    Y = np.fft.fft(d) / length
    magnitude = np.abs(Y)[0:int(length / 2)]
    phase = np.angle(Y)[0:int(length / 2)]
    freq = np.fft.fftfreq(length, 1 / fs)[0:int(length / 2)]
    return freq, magnitude, phase


solver = s.LMM_sys(PG.M, PG.C, PG.K, PG.T, X0, Xd0, timerange, solver_options={"beta_1": 0.55, "beta_2": 0.4})

#tnm = time.time()
#sol_nm = solver.solve_de("Newmark")
#print("Newmark time: ", time.time() - tnm)

trk = time.time()
sol = solver.solve_de("RK")
print("Runge Kutta time: ", time.time() - trk)

# t_stiff = time.time()
# sol = solver.solve_de("Radau")
# print("Radau time: ", time.time() - t_stiff)

# t_stiff = time.time()
# sol_bdf = solver.solve_de("BDF")
Esempio n. 8
0
 def sys_model_deterministic(m1):
     M = np.eye(dim)
     M[0, 0] = m1
     lmm = s.LMM_sys(M, C, K, f, X0, Xd0, t)
     sol = lmm.solve_de("RK")
     return sol[:, -1]
Esempio n. 9
0
 def make_measurements(m1):
     M = np.eye(dim)
     M[0, 0] = m1
     lmm = s.LMM_sys(M, C, K, f, X0, Xd0, t)
     sol = lmm.solve_de("RK")
     return sol[:, -1]