Files

objectiveGrad.m
function O = objectiveGrad(wp,wx,wy,wz,P,Pa,Paa,Paaa,K1,K2,Psum,Pasum,Paasum,Paaasum) % OBJECTIVEGRAD Returns gradient of the objective function [dUxx, dUyy, dUzz] = potentialdiff(P,Pa,Paa,Paaa,K1,K2,Psum,Pasum,Paasum,Paaasum); O = wp*dotProductdiff(P,P,Psum,Psum) - dUxx*wx - dUyy*wy - dUzz*wz; end function dp = dotProductdiff(pg, pf, pgsum, pfsum) dp = imag(pfsum)*real(pg) + imag(pgsum)*real(pf) ... - real(pfsum)*imag(pg) - real(pgsum)*imag(pf); end function [Uxx, Uyy, Uzz] = potentialdiff(P,Pa,Paa,Paaa,K1,K2,Psum,Pasum,Paasum,Paaasum) % Uaa = 2*K1*(dotproductdiff(pa,pa,transducer) + dotproductdiff(p,paa,transducer)) ... % - 2*K2*(dotproductdiff(pxa,pxa,transducer) + dotproductdiff(px,pxaa,transducer) ... % + dotproductdiff(pya,pya,transducer) + dotproductdiff(py,pyaa,transducer) ... % + dotproductdiff(pya,pya,transducer) + dotproductdiff(py,pyaa,transducer)); PxzPxz = dotProductdiff(Paa(:,3),Paa(:,3),Paasum(:,3),Paasum(:,3)); PxyPxy = dotProductdiff(Paa(:,2),Paa(:,2),Paasum(:,2),Paasum(:,2)); PyzPyz = dotProductdiff(Paa(:,5),Paa(:,5),Paasum(:,5),Paasum(:,5)); Uxx = 2*K1*(dotProductdiff(Pa(:,1),Pa(:,1),Pasum(:,1),Pasum(:,1)) + dotProductdiff(P,Paa(:,1),Psum,Paasum(:,1))) ... - 2*K2*(dotProductdiff(Paa(:,1),Paa(:,1),Paasum(:,1),Paasum(:,1)) + dotProductdiff(Pa(:,1),Paaa(:,1),Pasum(:,1),Paaasum(:,1)) ... + PxyPxy + dotProductdiff(Pa(:,2),Paaa(:,4),Pasum(:,2),Paaasum(:,4)) ... + PxzPxz + dotProductdiff(Pa(:,3),Paaa(:,7),Pasum(:,3),Paaasum(:,7))); Uyy = 2*K1*(dotProductdiff(Pa(:,2),Pa(:,2),Pasum(:,2),Pasum(:,2)) + dotProductdiff(P,Paa(:,4),Psum,Paasum(:,4))) ... - 2*K2*(PxyPxy + dotProductdiff(Pa(:,1),Paaa(:,2),Pasum(:,1),Paaasum(:,2)) ... + dotProductdiff(Paa(:,4),Paa(:,4),Paasum(:,4),Paasum(:,4)) + dotProductdiff(Pa(:,2),Paaa(:,5),Pasum(:,2),Paaasum(:,5)) ... + PyzPyz + dotProductdiff(Pa(:,3),Paaa(:,8),Pasum(:,3),Paaasum(:,8))); Uzz = 2*K1*(dotProductdiff(Pa(:,3),Pa(:,3),Pasum(:,3),Pasum(:,3)) + dotProductdiff(P,Paa(:,6),Psum,Paasum(:,6))) ... - 2*K2*(PxzPxz + dotProductdiff(Pa(:,1),Paaa(:,3),Pasum(:,1),Paaasum(:,3)) ... + PyzPyz + dotProductdiff(Pa(:,2),Paaa(:,6),Pasum(:,2),Paaasum(:,6)) ... + dotProductdiff(Paa(:,6),Paa(:,6),Paasum(:,6),Paasum(:,6)) + dotProductdiff(Pa(:,3),Paaa(:,9),Pasum(:,3),Paaasum(:,9))); end
Report a bug