def gradfunc(x, f, g): grad_obj = [0] * 2 grad_obj[:] = objGrad(x) grad_con = np.zeros((2, 2)) try: _, mpp_stress, _ = pma( func=lambda u: fcn_g_stress(u, d=x, theta=theta), gradFunc=lambda u: grad_g_stress(u, d=x, theta=theta), u0=u0, pf=pf_stress, tfmJac=lambda u: dUdT(u, theta=theta), That=That, C=Con) grad_con[0] = -sens_g_stress(U=mpp_stress, d=x, theta=theta) _, mpp_disp, _ = pma( func=lambda u: fcn_g_disp(u, d=x, theta=theta), gradFunc=lambda u: grad_g_disp(u, d=x, theta=theta), u0=u0, pf=pf_disp, tfmJac=lambda u: dUdT(u, theta=theta), That=That, C=Con) grad_con[1] = -sens_g_disp(U=mpp_disp, d=x, theta=theta) fail = 0 except ValueError: fail = 1 return grad_obj, grad_con, fail
def objfunc(x): # f = objective value # g = [-gc_stress, -gc_disp] f = obj(x) g = [0] * 2 try: gc_stress, _, _ = pma( func=lambda u: fcn_g_stress(u, d=x, theta=theta), gradFunc=lambda u: grad_g_stress(u, d=x, theta=theta), u0=u0, pf=pf_stress, tfmJac=lambda u: dUdT(u, theta=theta), That=That, C=Con) g[0] = -gc_stress gc_disp, _, _ = pma( func=lambda u: fcn_g_disp(u, d=x, theta=theta), gradFunc=lambda u: grad_g_disp(u, d=x, theta=theta), u0=u0, pf=pf_disp, tfmJac=lambda u: dUdT(u, theta=theta), That=That, C=Con) g[1] = -gc_disp fail = 0 except ValueError: fail = 1 return f, g, fail
def run_FORM(d): fcn = lambda u: fcn_g_stress(u, d=d) / scale grd = lambda u: grad_g_stress(u, d=d) / scale tfm = lambda u: dUdT(u) u0 = np.ones(4) / np.sqrt(4) g_cr, mpp, dgdU = pma(func=fcn, gradFunc=grd, u0=u0, pf=0.1, tfmJac=tfm, That=np.diag([0.] * 4)) return g_cr, mpp
d0 = np.array([2.6999, 3.4098]) ## Exact reliability analysis pf_stress_ext = 1 - R_stress(d0) print("pf_stress_ext = {}".format(pf_stress_ext)) ## MCS G_stress = fcn_g_stress(U, d=d0) pf_stress_hat = np.mean(G_stress <= 0) print("pf_stress_hat = {}".format(pf_stress_hat)) ## PMA tfm = lambda u: dUdT(u) fcn_stress = lambda u: fcn_g_stress(u, d=d0) / 1e4 grd_stress = lambda u: grad_g_stress(u, d=d0) / 1e4 g_cr_stress, mpp_stress, dgdU_stress = pma(fcn_stress, grd_stress, u0, pf_stress_ext, tfm, That) print("g_stress = {0:5.4f}".format(g_cr_stress)) # print("mpp = {}".format(mpp)) # print("dgdU = {}".format(dgdU)) ## Displacement ## -------------------------------------------------- d0 = np.array([2.448387, 3.888371]) ## Analysis via Davies algorithm pf_disp_ext = 1 - R_disp(d0) print("pf_disp_ext = {}".format(pf_disp_ext)) ## MCS G_disp = fcn_g_disp(U, d=d0) pf_disp_hat = np.mean(G_disp <= 0)