Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Quad2d accuracy

Subject: Quad2d accuracy

From: doron bartov

Date: 31 May, 2012 07:27:31

Message: 1 of 6

Hi,
i am using quad2d to calculate a surface integral, so far it apears that my results are around 60%-100% accurate, should i expect something more precise? with another function maybe?

Subject: Quad2d accuracy

From: Torsten

Date: 31 May, 2012 07:42:29

Message: 2 of 6

On 31 Mai, 09:27, "doron bartov" <doronbar...@gmail.com> wrote:
> Hi,
> i am using quad2d to calculate a surface integral, so far it apears that my results are around 60%-100% accurate, should i expect something more precise? with another function maybe?

By strengthening the tolerances AbsTol and RelTol of quad2d ?

Best wishes
Torsten.

Subject: Quad2d accuracy

From: Roger Stafford

Date: 31 May, 2012 07:53:25

Message: 3 of 6

"doron bartov" <doronbartov@gmail.com> wrote in message <jq76h3$21a$1@newscl01ah.mathworks.com>...
> Hi,
> i am using quad2d to calculate a surface integral, so far it apears that my results are around 60%-100% accurate, should i expect something more precise? with another function maybe?
- - - - - - - - - -
  That doesn't sound very accurate. What are your integrand function and limits of integration. What do you have your error tolerances set at? How do you know the accuracy? Is it something you already know the answer to?

Roger Stafford

Subject: Quad2d accuracy

From: doron bartov

Date: 31 May, 2012 08:16:33

Message: 4 of 6

i am calculating an electro magnetic physical quantity- the cross factor of the electric field and magnetic field emerging from an electric dipole.
my limits are : thetha=[0-pi], phi=[0-2pi].
when i set tollerance values it did not help the accuracy.
i know (not sure) the answer from the answer of the other side of the equation (dot(E,J))



"Roger Stafford" wrote in message <jq781l$7m2$1@newscl01ah.mathworks.com>...
> "doron bartov" <doronbartov@gmail.com> wrote in message <jq76h3$21a$1@newscl01ah.mathworks.com>...
> > Hi,
> > i am using quad2d to calculate a surface integral, so far it apears that my results are around 60%-100% accurate, should i expect something more precise? with another function maybe?
> - - - - - - - - - -
> That doesn't sound very accurate. What are your integrand function and limits of integration. What do you have your error tolerances set at? How do you know the accuracy? Is it something you already know the answer to?
>
> Roger Stafford

Subject: Quad2d accuracy

From: Steven_Lord

Date: 31 May, 2012 13:36:27

Message: 5 of 6



"doron bartov" <doronbartov@gmail.com> wrote in message
news:jq79d1$cuh$1@newscl01ah.mathworks.com...
> i am calculating an electro magnetic physical quantity- the cross factor
> of the electric field and magnetic field emerging from an electric dipole.
> my limits are : thetha=[0-pi], phi=[0-2pi].
> when i set tollerance values it did not help the accuracy.
> i know (not sure) the answer from the answer of the other side of the
> equation (dot(E,J))

Can you show the integral you're trying to compute and the code that you
wrote to compute it? Perhaps one of the readers of the group can detect if
there's a typo or other type of error in the code.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: Quad2d accuracy

From: doron bartov

Date: 31 May, 2012 15:34:19

Message: 6 of 6

the integrand is ( E cross H* ) dot da d(theha) d(phi)

the boundaries are thetha=[0 pi], phi=[0 2pi]

the function that calculates it is below

function [loss_EM_energy, Electric_Ftotal]= poynting_on_surface(waveVec, Pvector, dipole_array_pos, error)

r_size=5*10^-8;
dipole_array_pos=dipole_array_pos(:,1:3);
waveVec_size=norm(waveVec);
omega=c*waveVec_size;
loss_EM_energy = quad2d(@fun,0,pi,0,2*pi,'AbsTol', error);



function integrand=fun(thetha,phi)
integrand=zeros(size(thetha));
    
for ThethaInd=1:size(thetha,2)
    for phiInd=1:size(phi,1)
        [x,y,z] = sph2cart(thetha(phiInd,ThethaInd),phi(phiInd,ThethaInd),r_size);
        Einc=incident_field(waveVec, [x y z]);
        Electric_Ftotal=Einc;
        HField_total=cross(waveVec,Einc)/(omega*4*pi*10^-7);
        for dipole_part_num=1:size(dipole_array_pos,1)
            dipole_array_vector=Pvector(3*dipole_part_num-2:3*dipole_part_num).';
vec_dip_point=[x,y,z] -dipole_array_pos(dipole_part_num,:);
vec_dip_point_norm=vec_dip_point/norm(vec_dip_point);
dist_dip_point=norm(vec_dip_point);
GreenTerm=exp(-1i*waveVec_size*dist_dip_point)/dist_dip_point;
ElecField=(waveVec_size^2*(cross(cross(vec_dip_point_norm,dipole_array_vector),vec_dip_point_norm))+(3*vec_dip_point_norm*dot(vec_dip_point_norm,dipole_array_vector)-dipole_array_vector)*(1/dist_dip_point^2+1i*waveVec_size/dist_dip_point))*GreenTerm;
ElecField_div_epsilon=ElecField/(4*pi*epsilon_b);
Electric_Ftotal=Electric_Ftotal+ElecField_div_epsilon;
HField=(c*waveVec_size^2/(4*pi))*cross(vec_dip_point_norm,dipole_array_vector)*GreenTerm*(1+1/(1i*waveVec_size*dist_dip_point));
HField_total=HField_total+HField;
        end
poynting_vector=cross(Electric_Ftotal,conj(HField_total));
da=r_size^2*sin(thetha(phiInd,ThethaInd))*[x y z]/r_size;
integrand(phiInd,ThethaInd)=integrand(phiInd,ThethaInd)+dot(poynting_vector,da);
    end
end
end
end

"Steven_Lord" <slord@mathworks.com> wrote in message <jq7s4s$sjn$1@newscl01ah.mathworks.com>...
>
>
> "doron bartov" <doronbartov@gmail.com> wrote in message
> news:jq79d1$cuh$1@newscl01ah.mathworks.com...
> > i am calculating an electro magnetic physical quantity- the cross factor
> > of the electric field and magnetic field emerging from an electric dipole.
> > my limits are : thetha=[0-pi], phi=[0-2pi].
> > when i set tollerance values it did not help the accuracy.
> > i know (not sure) the answer from the answer of the other side of the
> > equation (dot(E,J))
>
> Can you show the integral you're trying to compute and the code that you
> wrote to compute it? Perhaps one of the readers of the group can detect if
> there's a typo or other type of error in the code.
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us