Beispiel #1
0
        wq = pc.W(q)

        # Set the paramter values into the element
        dspr.setStiffness(yq['K'])

        # Create space for fetching deterministic
        # jacobian, and state vectors that go as input
        uq = np.zeros((nddof))
        lamq = np.zeros((nddof))
        for k in range(nterms):
            psiky = pc.evalOrthoNormalBasis(k, q)
            uq[:] += U[k * nddof:(k + 1) * nddof] * psiky
            lamq[:] += lam[k * nddof:(k + 1) * nddof] * psiky

        # Evaluate function
        dfdxq = dspr.getAdjointDeriv(uq, lamq)

        # Project the determinic initial conditions onto the
        # stochastic basis
        psiziw = wq * pc.evalOrthoNormalBasis(i, q)
        fitmp += dfdxq * psiziw

    # Set into the force vector
    dFdX[i] = fitmp

fmeanprime = dFdX[0]
fvarprime = np.sum(2 * E[1:] * dFdX[1:])
fstdprime = fvarprime / (2.0 * np.sqrt(fvar))

print('stochastic galerkin adjoint')
print("fmean : %15.14f" % fmean, "fmeanprime : %15.14f" % fmeanprime)