Compute the analytical partial derivative of the nodal displacements.
dU = dfemtruss_ana(ffd,U,listofnodes,Log,varargin)
a function which returns the parameters of a structure. Must have the following prototype: [t,p,e,A,E,rho,F] = ffd(varargin(1)). The varargin(1) parameters is optional.
the vector of nodal displacement.
a list of nodes where to compute the partial derivative
if %T
, then print some intermediate messages.
some optional parameters sent to ffd
.
partial derivative of the nodal displacement solution (wrt to the points given in listof nodes). A matrix of size 3*length(listofnodes) x length(U) for a 3 dimensions structure and 2*length(listofnodes) x length(U) for a 2 dimensions structure.
Compute the analytical partial derivative of the nodal displacements.
// Code sample extracted from demos/brid_optim_analytical.sce // This code will not work if copy / pasted from this help page ! function y=fobj_truss(x) [t,p,e,A,E,rho,F] = bridge_optim(x); [U,P,R]= femtruss(bridge_optim, %F, x); y = sum(U(IndexNodeVarInf).^2); endfunction function dy=dfobj_truss(x) // Here, we will compute analytical derivatives for the objective function. // We use dfemtruss to compute analytical derivatives for displacement // We then compute by hand the analytical derivative for the objective function using the result of dfemtruss [t,p,e,A,E,rho,F] = bridge_optim(x); [U,P,R]= femtruss(bridge_optim, %F, x); // The deck - 3 4 5 Pos_deck = localise2d(IndexNodeVarInf); // The degree of freedom for the optimization - 6 7 8 Pos_free = localise2d(IndexNodeVarSup); dU = dfemtruss_ana(bridge_optim,U,[],%F, x); dy = zeros(length(Pos_free),1); // dU contains only partial derivatives for nodes 2 3 and 4. So, we get partial derivatives with respect to y by accessing // value 2 4 and 6. Values 1 3 and 5 are partial derivatives wrt x. // dU(I4,[I1 I2 I3]) = dU(I1) / dI4 dU(I2) / dI4 dU(I3) / dI4 for i=1:length(Pos_free) dy(i) = 2*sum(dU(Pos_free(i), Pos_deck(2:2:$)).*U(Pos_deck(2:2:$))); end endfunction function [y, dy, ind]=optim_fobj_truss(x, ind) y = fobj_truss(x); dy = dfobj_truss(x)'; if Debug then printf('y = %f norm(dy) = %f\n',y, norm(dy)); end endfunction | ![]() | ![]() |