本文采用普通帖子模式,而不是使用Markdown 格式发帖,测试是否可以加入数学公式;
一、数学公式 Introduction
This example shows how Global Optimization Toolbox functions,
particularly |GlobalSearch| and |MultiStart|, can help locate the maximum
of an electromagnetic interference pattern. For simplicity of modeling,
the pattern arises from monochromatic polarized light spreading out from
point sources.
$$E_i = \frac{A_i}{d_i(x)} \sin(\phi_i + \omega (t - d_i(x)/c) ),$$ where $\phi_i$ is the phase at time zero for source $i$, $c$ is the speed
of light, $\omega$ is the frequency of the light, $A_i$ is the amplitude
of source $i$, and $d_i(x)$ is the distance from source $i$ to $x$.
For a fixed point $x$ the intensity of the light is the time average of
the square of the net electric field. The net electric field is sum of
the electric fields due to all sources. The time average depends only on
the sizes and relative phases of the electric fields at $x$. To calculate
the net electric field, add up the individual contributions using the
phasor method. For phasors, each source contributes a vector. The length
of the vector is the amplitude divided by distance from the source, and
the angle of the vector, $\phi_i - \omega d_i(x)/c$ is the phase at the
point.
For this example, we define three point sources with the same frequency
($\omega$) and amplitude ($A$), but varied initial phase ($\phi_i$). We
arrange these sources on a fixed plane.
- % Frequency is proportional to the number of peaks
- relFreqConst = 2*pi*2.5;
- amp = 2.2;
- phase = -[0; 0.54; 2.07];
- numSources = 3;
- height = 3;
- % All point sources are aligned at [x_i,y_i,z]
- xcoords = [2.4112
- 0.2064
- 1.6787];
- ycoords = [0.3957
- 0.3927
- 0.9877];
- zcoords = height*ones(numSources,1);
- origins = [xcoords ycoords zcoords];
We are interested in the location where this wave intensity reaches
its highest peak.
The wave intensity ($I$) falls off as we move away from the source
proportional to $1/d_i(x)$. Therefore, let's restrict the space of
viable solutions by adding constraints to the problem.
Now our problem has become:
$$ \max_{x,y} I(x,y) $$
subject to
$$ (x - x_{c1})^2 + (y - y_{c1})^2 \le r_1^2 $$
$$ (x - x_{c2})^2 + (y - y_{c2})^2 \le r_2^2 $$
$$ (x - x_{c3})^2 + (y - y_{c3})^2 \le r_3^2 $$
$$-0.5 \leq x \leq 3.5$$
$$-2 \leq y \leq 3$$
where $(x_{cn},y_{cn})$ and $r_n$ are the coordinates and aperture radius
of the $n^{th}$ point source, respectively. Each source is given an
aperture with radius 3. The given bounds encompass the feasible region.
The objective ($I(x,y)$) and nonlinear constraint functions are defined
in separate MATLAB(R) files, |waveIntensity.m| and |apertureConstraint.m|,
respectively, which are listed at the end of this example.
- % Visualize the contours of our interference surface
- domain = [-3 5.5 -4 5];
- figure;
- ezcontour(@(X,Y) arrayfun(@(x,y) waveIntensity_x([x y]),X,Y),domain,150);
- hold on
- % Plot constraints
- g1 = @(x,y) (x-xcoords(1)).^2 + (y-ycoords(1)).^2 - 9;
- g2 = @(x,y) (x-xcoords(2)).^2 + (y-ycoords(2)).^2 - 9;
- g3 = @(x,y) (x-xcoords(3)).^2 + (y-ycoords(3)).^2 - 9;
- h1 = ezplot(g1,domain);
- h1.Color = [0.8 0.7 0.1]; % yellow
- h1.LineWidth = 1.5;
- h2 = ezplot(g2,domain);
- h2.Color = [0.3 0.7 0.5]; % green
- h2.LineWidth = 1.5;
- h3 = ezplot(g3,domain);
- h3.Color = [0.4 0.4 0.6]; % blue
- h3.LineWidth = 1.5;
- % Plot bounds
- lb = [-0.5 -2];
- ub = [3.5 3];
- line([lb(1) lb(1)],[lb(2) ub(2)],'LineStyle','--')
- line([ub(1) ub(1)],[lb(2) ub(2)],'LineStyle','--')
- line([lb(1) ub(1)],[lb(2) lb(2)],'LineStyle','--')
- line([lb(1) ub(1)],[ub(2) ub(2)],'LineStyle','--')
- title('Pattern Contours with Constraint Boundaries')
结束语:
我也是在不断的测试,希望在明年有较好的教学课程发布论坛。




雷达卡




京公网安备 11010802022788号







