Beispiel #1
0
                                             w_tensor,
                                             v_tensor,
                                             X_tensor[0, :],
                                             tf.constant(ncp),
                                             g,
                                             h,
                                             u=u_tensor)
    Yhat = Yhat_tensor.numpy().T
    x1_koopman = Yhat[0, :]
    x2_koopman = Yhat[2, :]
    print('FINISHED with predictions')

    ############################################################################
    # Perform DMD for comparison
    ############################################################################
    lam_dmd, w_dmd, v_dmd, _ = dmd.get_dmd_modes(X, Y)
    Yhat_dmd = dmd.predict(lam_dmd, w_dmd, v_dmd, X[:, 0], ncp, u=u)
    x1_dmd = Yhat_dmd[0, :]
    x2_dmd = Yhat_dmd[2, :]

    ############################################################################
    # Plot
    ############################################################################
    print('PLOTS')
    plt.figure()
    plt.title('Simulated data and m={}'.format(m_stop))
    plt.plot(t, x1_target, '-b', linewidth=2)
    plt.plot(t, x1_dmd, '--r', linewidth=2)
    plt.plot(t, x1_koopman, '-.k', linewidth=2)
    plt.legend(('Simulated solution', 'DMD', 'Koopman'))
    plt.xlim(0, dt * (ncp))
Beispiel #2
0
    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, :]

    # Step size
    dt = (t_stop - t_start) / ncp
Beispiel #3
0
        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, :]

    # Step size
    dt = (t_stop - t_start) / ncp