[Physics application] Calculation of corrosion potential based on matlab two-dimensional boundary element method [including Matlab source code 523]

1. Introduction

Calculation of corrosion potential based on matlab two-dimensional boundary element method

Second, the source code

clear;

fid=fopen('input.dat','r');
indat=fscanf(fid,'%g%g%d%g',[4,inf]);
indat=indat';
xb=indat(:,1);
yb=indat(:,2);
bt=indat(:,3);
bv=indat(:,4);
n=length(xb)-1;

for i=1:n
    xm(i)=0.5d0*(xb(i)+xb(i+1));
    ym(i)=0.5d0*(yb(i)+yb(i+1));
    lm(i)=sqrt((xb(i+1)-xb(i))^2d0+(yb(i+1)-yb(i))^2d0);
    nx(i)=(yb(i+1)-yb(i))/lm(i);
    ny(i)=(xb(i)-xb(i+1))/lm(i);
end

for m=1:n
    b(m)=0d0;
    for k=1:n
        if(k==m)
            G=0.0;
            F=lm(k)/(2.0*pi)*(log(lm(k)/2.0)-1.0);
            del=1.0;
        else
            [F,G]=findfg(xm(m),ym(m),xb(k),yb(k),nx(k),ny(k),lm(k));
            del=0.0;
        end
        if(bt(k)==0)
            A(m,k)=-F;
            b(m)=b(m)+bv(k)*(-G+0.5d0*del);
        else
            A(m,k)=G-0.5d0*del;
            b(m)=b(m)+bv(k)*F;
        end
    end
end
z=A\b';

for m=1:n
   u(m)=(1-bt(m))*bv(m)+bt(m)*z(m);
   q(m)=(1-bt(m))*z(m)+bt(m)*bv(m);
end

for j=1:9
   y(j)=0.1*j;
   for i=1:9
      x(i)=0.1*i;
      s(j,i)=0d0;
      for k=1:n
         [F,G]=findfg(x(i),y(j),xb(k),yb(k),nx(k),ny(k),lm(k));
         s(j,i)=s(j,i)+u(k)*G-q(k)*F;
      end
   end
end

Three, running results

Insert picture description here

Four, remarks

Complete code or writing add QQ 1564658423 past review
>>>>>>
[Physics application] based on matlab Young’s double-slit interference experiment [including Matlab source code 001]
[Physics application] based on matlab wellbore multiphase flow [including Matlab source code Issue 055]
[Physics application] Two-dimensional convective diffusion temperature field based on matlab [Including Matlab source code 056]
[Physics application] Based on matlab interior ballistics [Including Matlab source code 057]
[Physics application] New photons based on two matlab fiber gratings Microwave generator simulation analysis [Including Matlab source code 058]
[Physics application] Calculating oil and gas well bottom hole pressure based on matlab [Including Matlab source code 059]
[Physics application] Based on matlab optical flow field [Including Matlab source code 060]
[Physics Application] Based on matlab simulation of chaotic motion of charged particles under radial electric field and uniform magnetic field [including Matlab source code 061]
[Physics application] Based on matlab heterogeneous traffic flow [including Matlab source code 062]
[Physics application] Matlab simulation of oblique throwing Motion with GUI interface [Including Matlab source code 063]
[Physics application] Matlab calculation of X-ray diffraction pattern of crystal structure [Including Matlab source code 064]
[Physics application] Matlab based diffraction grating teaching edition [Including Matlab source code 065]
[ Physics application] based on matlab electric field line and electric potential [including Matlab source code 066]
[Physics application] based on matlab velocity field to find vortex [including Matlab source code 067]
[Physics application] based on matlab lane detection simulation [including Matlab source code 068]
[Physics application] Electric dipole based on matalb GUI interface [Including Matlab source code 069]
[Physics application] Research on roadside performance and anti-collision algorithm based on matlab vehicle self-organizing network [Including Matlab source code 263]
[Physics application] Based on Matlab Q-learning wireless body area network routing method [Including Matlab source code 264]
[Physical application] Based on matlab GUI home indoor temperature and humidity control [Including Matlab source code 326]
[Circuit simulation] Based on simulink three-phase phase control converter Design [Including Matlab source code 327]
[Physics application] Matlab-based wire mesh coordinate calculation [Including Matlab source code 328]
[Physics application] Matlab-based power spectrum estimation [Including Matlab source code 329]
[Physics application] Based on dynamic matrix Control method of water heater outlet temperature control [Including Matlab source code 330]
[Circuit simulation] Based on matlab simulink three-phase half-wave controllable rectifier circuit [Including Matlab source code 331]
[Circuit simulation] Based on matlab simulink three-phase bridge fully controlled rectifier Circuit [Including Matlab source code 332]
[Circuit simulation] Based on simulink analog phase-locked loop design [Including Matlab source code 339]
[Circuit simulation] Based on simulink all-digital phase-locked loop design [Including Matlab source code 340]
[Physical application] Based on Power system power flow calculation
based on matlab rectangular coordinates [including Matlab source code 341] [Optics] based on matlab single-slit diffraction [including Matlab source code 342]
[Physics application] based on matlab RBF neural network algorithm to control satellite orbit and attitude [including Matlab source code 377 period】
[Physics application] based on matlab traffic light vehicle number recognition [including Matlab source code 378]
[Circuit simulation] PID control based on simulink quadrotor [including Matlab source code 454]
[Optics] Double slit interference based on matlab GUI light [including Matlab source code Issue 455]
[Circuit Simulation] Based on Matlab Photovoltaic Cell Simulink Simulation Model [Including Matlab Source Code 486]
[Physical Application] Based on Matlab PIC Model of Solar Wind Particle Simulation [Including Matlab Source Code 493]
[Optics] Based on Matlab Grating Diffraction Simulation [Including Matlab source code 502]
[Physics application] Matlab wavenumber spectrum calculation [including Matlab source code 508]
[Physics application] Matlab simulation of circular hole based Fresnel diffraction [Matlab source code 522]

Guess you like

Origin blog.csdn.net/TIQCmatlab/article/details/114853881