def m_model(input_location, input_scale):
    dLInputScaling = getScalingDenseLayer(input_location, input_scale)
    L1 = Dense(10)
    L2 = Dense(5)
    L3 = Dense(1, activation='linear', trainable=True)
    model = Sequential([dLInputScaling, L1, L2, L3], name='m_mlp')

    optimizer = RMSprop(1e-3)
    model.compile(loss='mse', optimizer=optimizer, metrics=['mae'])
    return model
Beispiel #2
0
def logC_model(input_location, input_scale):
    dLInputScaling = getScalingDenseLayer(input_location, input_scale)
    L1 = Dense(40, activation='elu')
    L2 = Dense(20, activation='elu')
    L3 = Dense(10, activation='elu')
    L4 = Dense(5, activation='elu')
    L5 = Dense(1, activation='elu', trainable=True)
    model = Sequential([dLInputScaling, L1, L2, L3, L4, L5], name='c_mlp')

    optimizer = RMSprop(1e-3)
    model.compile(loss='mse', optimizer=optimizer, metrics=['mae'])
    return model
Beispiel #3
0
def arch_model(switch, input_location, input_scale):
    dLInputScaling = getScalingDenseLayer(input_location, input_scale)
    if switch == 1:
        L1 = Dense(5, activation = 'tanh')
        L2 = Dense(1, activation = 'linear')
        model = Sequential([dLInputScaling,L1,L2], name = 'bias_mlp')
        model.compile(loss='mse', optimizer=RMSprop(1e-3), metrics=['mae']) 
    elif switch == 2:
        L1 = Dense(10, activation = 'elu')
        L2 = Dense(5, activation = 'elu')
        L3 = Dense(1, activation = 'linear')
        model = Sequential([dLInputScaling,L1,L2,L3], name = 'bias_mlp')
        model.compile(loss='mse', optimizer=RMSprop(1e-3), metrics=['mae'])
    elif switch == 3:
        L1 = Dense(10, activation = 'elu')
        L2 = Dense(5, activation = 'sigmoid')
        L3 = Dense(1, activation = 'elu')
        model = Sequential([dLInputScaling,L1,L2,L3], name = 'bias_mlp')
        model.compile(loss='mse', optimizer=RMSprop(1e-3), metrics=['mae'])
    elif switch == 4:
        L1 = Dense(10, activation = 'tanh')
        L2 = Dense(5, activation = 'tanh')
        L3 = Dense(1, activation = 'elu')
        model = Sequential([dLInputScaling,L1,L2,L3], name = 'bias_mlp')
        model.compile(loss='mse', optimizer=RMSprop(1e-3), metrics=['mae'])
    elif switch == 5:
        L1 = Dense(20, activation = 'tanh')
        L2 = Dense(10, activation = 'elu')
        L3 = Dense(5, activation = 'sigmoid')
        L4 = Dense(1, activation = 'linear', trainable = True)
        model = Sequential([dLInputScaling,L1,L2,L3,L4], name = 'bias_mlp')
        model.compile(loss='mse', optimizer=RMSprop(1e-3), metrics=['mae'])
    elif switch == 6:
        L1 = Dense(20, activation = 'elu')
        L2 = Dense(10, activation = 'sigmoid')
        L3 = Dense(5, activation = 'sigmoid')
        L4 = Dense(1, activation = 'elu', trainable = True)
        model = Sequential([dLInputScaling,L1,L2,L3,L4], name = 'bias_mlp')
        model.compile(loss='mse', optimizer=RMSprop(1e-3), metrics=['mae'])
    elif switch == 7:
        L1 = Dense(40, activation = 'elu')
        L2 = Dense(20, activation = 'sigmoid')
        L3 = Dense(10, activation = 'sigmoid')
        L4 = Dense(1, activation = 'elu', trainable = True)
        model = Sequential([dLInputScaling,L1,L2,L3,L4], name = 'bias_mlp')
        model.compile(loss='mse', optimizer=RMSprop(1e-3), metrics=['mae'])
    return model
Beispiel #4
0
                Dense(1,activation = 'sigmoid')
                ], name='plane_delgrs_mlp')
        optimizer = RMSprop(0.01)
        model.compile(loss='mean_squared_error',
                      optimizer=optimizer,
                      metrics=['mean_absolute_error', 'mean_squared_error'])
        return model
    
    parent_dir = os.path.dirname(os.getcwd())
    
    dfPlane = pd.read_csv(parent_dir+'\data\\random_plane_set_500_adv.csv')

    inputsMLPTrain = dfPlane[['Dkappa','dynamicLoads','bearingTemp']]
    inputsMLPTrain_min = inputsMLPTrain.min(axis=0)
    inputsMLPTrain_range = inputsMLPTrain.max(axis=0) - inputsMLPTrain_min
    dLInputScaling = getScalingDenseLayer(inputsMLPTrain_min,inputsMLPTrain_range)
        
    MLPmodel = build_model(dLInputScaling)

    outputsMLPTrain = dfPlane[['delDkappa']]
    outputsMLPTrain_min = outputsMLPTrain.min(axis=0)
    outputsMLPTrain_range = outputsMLPTrain.max(axis=0) - outputsMLPTrain_min
    outputsMLPTrain_norm = (outputsMLPTrain - outputsMLPTrain_min)/outputsMLPTrain_range
    
    dfTrueDOE = pd.read_csv(parent_dir+'\data\\true_set_500_adv.csv')

    inputsMLPPred = dfTrueDOE[['Dkappa','dynamicLoads','bearingTemp']]
    
    outputsMLPPred = dfTrueDOE[['delDkappa']]
    outputsMLPPred_min = outputsMLPPred.min(axis=0)
    outputsMLPPred_range = outputsMLPPred.max(axis=0) - outputsMLPPred_min
plastic_io = pd.read_csv('./plastic_deflections2.csv',
                         index_col=False,
                         header=None)

force_input = np.asarray(plastic_io)[0, :]
plastic_deflections = np.asarray(plastic_io)[1:, :]

F_matrix[-1] += -NBC[-1]
force_vector = F_matrix

physics_model = create_physics_model(np.array([A_matrix]), force_vector, 2e5,
                                     6e5, force_input.shape, 'float32')

elastic_deflection = physics_model.predict(force_input)
dLInputScaling = getScalingDenseLayer(
    np.array([force_input.min(axis=0)]),
    np.array([force_input.max(axis=0) - force_input.min(axis=0)]))

delta_stiffness_mlp = build_mlp(dLInputScaling, 'delta_stiffness')
delta_stiffness_mlp.trainable = True

force_mlp = build_force_mlp(dLInputScaling, 'delta_force')
force_mlp.trainable = True

fe_model = create_fe_model(force_mlp, delta_stiffness_mlp,
                           np.array([A_matrix]), force_vector, 1e1, 1e5, -1e3,
                           1e3, force_input.shape, 'float32')

#weight_path = "./test_50000EP/cp.ckpt"
#
#ModelCP = ModelCheckpoint(filepath=weight_path, monitor='loss',
    x = np.load('./data/x.npy', allow_pickle=True)
    xOBS = np.load('./data/x_obs.npy', allow_pickle=True)

    modulus_array = modulus_fit(x[:, 0], x[:, 1])
    stiffness_array = stiffness_var(radius, length, thickness, poisson,
                                    modulus_array[:, 0])
    damping_array = damping_var(inertia, stiffness_array, modulus_array[:, 0],
                                modulus_array[:, 1])
    stiffness_low = stiffness_array.min()
    stiffness_up = stiffness_array.max()
    damping_low = damping_array.min()
    damping_up = damping_array.max()

    input_min = x.min(axis=0)
    input_range = x.max(axis=0) - input_min
    input_scaling = getScalingDenseLayer(input_min, input_range)

    delta_stiffness_mlp = create_mlp(input_scaling, 'delta_stiffness')
    delta_damping_mlp = create_mlp(input_scaling, 'delta_damping')

    df = pd.read_csv('data/storage_modulus.csv')
    storageModulus = arrange_table(df)
    df = pd.read_csv('data/loss_modulus.csv')
    lossModulus = arrange_table(df)

    batch_input_shape = x.shape

    select_freq = [0]
    select_temp = [1]

    # Calculate outputs