예제 #1
0
    ]

    # Get snapshots, both simulated and analytical
    data_sim = dmd.get_koopman_snapshots_stop_friction(t_start,
                                                       t_stop,
                                                       ncp,
                                                       g,
                                                       input_force=u,
                                                       time_vec=t)
    data_an = dmd.get_analytical_snapshots_damped_dual_mass(t_start,
                                                            t_stop,
                                                            ncp,
                                                            input_force=u)

    # Get data matrices
    X, Y = dmd.get_data_matrices(data_sim, m_stop=m_stop, u=u, q=q)

    # Calculate DMD modes and eigenvalues
    lam, w, v, Ahat = dmd.get_dmd_modes(X, Y)

    # Predict the system
    Yhat = dmd.predict(lam, w, v, X[:, 0], ncp, u=u, q=q)

    # Plots
    # Extract results
    x1_dmd = Yhat[0, :]
    x2_dmd = Yhat[2, :]
    x1_sim = data_sim[0, :]
    x2_sim = data_sim[2, :]
    x1_an = data_an[0, :]
    x2_an = data_an[2, :]
예제 #2
0
        g = [x1, x2, x1**2]
        data = koopman_prob(data_an, g, ncp)
    else:
        method = 'DMD'
        data = data_an

    # Calculate stop index for training
    if not t_stop_train:
        m_stop = ncp + 1
    elif t_stop_train > t_stop:
        raise ValueError('t_stop_train must be <= t_stop.')
    else:
        m_stop = np.argmin(t < t_stop_train)

    # Construct X,Y from data
    X, Y = dmd.get_data_matrices(data, m_stop=m_stop, u=None, q=q)

    # Calculate DMD modes and eigenvalues
    lam, w, v, _ = dmd.get_dmd_modes(X, Y)

    # Predict the system
    Yhat = dmd.predict(lam, w, v, X[:, 0], ncp, u=None, q=q)

    # Extract results
    x1_dmd = Yhat[0, :]
    x2_dmd = Yhat[1, :]
    x1_sim = data_sim[0, :]
    x2_sim = data_sim[1, :]
    x1_an = data_an[0, :]
    x2_an = data_an[1, :]