예제 #1
0
stiffness_random_variable = \
    BetaRandomVariable(alpha=3., beta=2., shift=1., scale=2.5)

# Specify spring-mass system:
m = 1.5  # Deterministic mass.
state0 = [0., 0.]  # Initial conditions.
t_grid = np.arange(0., 10., 0.1)  # Time.

# Initialize model,
model = SpringMass1D(m, state0, t_grid)

# ----------Monte Carlo------------------

# Generate stiffness input samples for Monte Carlo.
num_samples = 5000
stiffness_samples = stiffness_random_variable.draw_random_sample(num_samples)

# Calculate maximum displacement samples using MC simulation.
displacement_samples = np.zeros(num_samples)
for i, stiff in enumerate(stiffness_samples):
    displacement_samples[i] = model.get_max_disp(stiff)

# Get Monte carlo solution as a sample-based random variable:
monte_carlo_solution = SampleRandomVector(displacement_samples)

# -------------SROM-----------------------

# Generate SROM for random stiffness.
srom_size = 10
dim = 1
input_srom = SROM(srom_size, dim)
예제 #2
0
#Random variable for spring stiffness
stiffness_rv = BetaRandomVariable(alpha=3., beta=2., shift=1., scale=2.5)

#Specify spring-mass system:
m = 1.5                             #deterministic mass
state0 = [0., 0.]                   #initial conditions
t_grid = np.arange(0., 10., 0.1)    #time 

#Initialize model
model = SpringMass_1D(m, state0, t_grid)

#----------Monte Carlo------------------

#Generate stiffness input samples for Monte Carlo
num_samples = 5000
stiffness_samples = stiffness_rv.draw_random_sample(num_samples)

#Calculate maximum displacement samples using MC simulation
disp_samples = np.zeros(num_samples)
for i, stiff in enumerate(stiffness_samples):
    disp_samples[i] = model.get_max_disp(stiff)

#Get Monte carlo solution as a sample-based random variable:
mc_solution = SampleRandomVector(disp_samples)

#-------------SROM-----------------------

#generate SROM for random stiffness
sromsize = 10
dim = 1
input_srom = SROM(sromsize, dim)