Article directory
0 Ideas for the competition
(Share on CSDN as soon as the competition questions come out)
https://blog.csdn.net/dc_sinor?type=blog
1 Question Requirements
Now it is known that a classroom is 15 meters long and 12 meters wide, and 4 light sources (1, 2, 3, 4) are
evenly , and the light intensity of each light source is one Unit, as
shown in the figure below:
- (1) How to calculate the light intensity at any point in the classroom? (The light intensity of the light source on the target point is inversely proportional to the square of the distance from the light source to the target point, and proportional to the intensity of the light source).
- (2) Draw a surface diagram of the functional relationship between the light intensity and the position (horizontal and vertical coordinates) of each point at a distance of 1 meter from the ground, and try to give an approximate functional relationship at the same time.
- (3) Assuming that the height of 1 meter from the ground is exactly the height of the students' desktops, how to design the positions of these four point light sources so that the students' average satisfaction with the lighting can be the highest?
- (4) If the point light source in the question is replaced with a line light source, what is the result of the above (2) and (3) questions?
(For (1) and (2), it is assumed that the distance between the horizontal (vertical) wall and the light source, the light source and the light source, and the light source and the wall are equal.)
2 Hypothetical conventions
- 1. Light does not pass through windows, doors, etc., and does not consider the consumption of light in the air, that is, the sum of light intensity remains unchanged;
- 2 The interior is not affected by external light sources;
- 3 The classroom height is 2.5 meters;
- 4 does not consider the reflection of light;
- The 5-line light source emits light evenly.
3 Notation Conventions
4 Build the model
5 Model Solving
6 Implementation code
Matlab implementation code
It is recommended to use python to implement it, the picture will look better, and the current domestic trend will gradually eliminate matlab. At present, some schools can no longer use matlab
clear
clc
max=0;min=4;
for i=0:0.1:3
for j=0.1:0.1:4
s=0;
x1=8+i,y1=5-j
x2=8+i,y2=10+j
x3=4-i,y3=10+j
x4=4-i,y4=5-j
for x=0:0.1:12
for y=0:0.1:15
for z=0:0.1:2.5
if x1~=x & y1~=y & x2~=x & y2~=y & x3~=x & y3~=y & x4~=x & y4~=y
s=s+1./((x1-x).^2+(y1-y).^2+(2.5-z).^2)+1./((x2-x).^2+(y2-y).^2+(2.5-z).^2)+1./((x3-x).^2+(y3-y).^2+(2.5-z).^2)+1./((x4-x).^2+(y4-y).^2+(2.5-z).^2);
end
end
end
end
k=4./s;l=0;z=1;
for x=0:0.1:12
for y=0:0.1:15
l=l+k.*(1./((x1-x).^2+(y1-y).^2+(2.5-z).^2)+1/((x2-x).^2+(y2-y).^2+(2.5-z).^2)+1./((x3-x).^2+(y3-y).^2+(2.5-z).^2)+1./((x4-x).^2+(y4-y).^2+(2.5-z).^2));
end
end
if l>max
max=l;
x11=x1;y11=y1;x12=x2;y12=y2;x13=x3;y13=y3;x14=x4;y14=y4;
end
p=l./(120.*150);Q=0;
for x=0:0.1:12
for y=0:0.1:15
Q=Q+(k.*(1./((x1-x).^2+(y1-y).^2+(2.5-z).^2)+1./((x2-x).^2+(y2-y).^2+(2.5-z).^2)+1./((x3-x).^2+(y3-y).^2+(2.5-z).^2)+1./((x4-x).^2+(y4-y).^2+(2.5-z).^2))-p).^2.^(1./2);
end
end
if min>Q
min=Q;
x21=x1;y21=y1;x22=x2;y22=y2;x23=x3;y23=y3;x24=x4;y24=y4;
end
end
end
disp(['最大值','x11=',num2str(x11),' ','y11=',num2str(y11),' ','x12=',num2str(x12),' ','y12=',num2str(y12),' ','x13=',num2str(x13),' ','y13=',num2str(y13),' ','x14=',num2str(x14),' ','y14=',num2str(y14)])
disp(['最平均','x21=',num2str(x21),' ','y21=',num2str(y21),' ','x22=',num2str(x22),' ','y22=',num2str(y22),' ','x23=',num2str(x23),' ','y23=',num2str(y23),' ','x24=',num2str(x24),' ','y24=',num2str(y24)])
附录二:
clear
clc
max=0;min=4;li=4;
for i=0:0.1:3
for j=0.1:0.1:4
s=0;
x1=8+i,y1=5-j
x2=8+i,y2=10+j
x3=4-i,y3=10+j
x4=4-i,y4=5-j
for x=0:0.1:12
for y=0:0.1:15
for z=0:0.1:2.5
if x1~=x & y1~=y & x2~=x & y2~=y & x3~=x & y3~=y & x4~=x & y4~=y
s=s+1./((x1-x).^2+(y1-y).^2+(2.5-z).^2)+1./((x2-x).^2+(y2-y).^2+(2.5-z).^2)+1./((x3-x).^2+(y3-y).^2+(2.5-z).^2)+1./((x4-x).^2+(y4-y).^2+(2.5-z).^2);
end
end
end
end
k=4./s;l=0;z=1;e=0
for x=0:0.1:12
for y=0:0.1:15
l=l+k.*(1./((x1-x).^2+(y1-y).^2+(2.5-z).^2)+1/((x2-x).^2+(y2-y).^2+(2.5-z).^2)+1./((x3-x).^2+(y3-y).^2+(2.5-z).^2)+1./((x4-x).^2+(y4-y).^2+(2.5-z).^2));
r=k.*(1./((x1-x).^2+(y1-y).^2+(2.5-z).^2)+1/((x2-x).^2+(y2-y).^2+(2.5-z).^2)+1./((x3-x).^2+(y3-y).^2+(2.5-z).^2)+1./((x4-x).^2+(y4-y).^2+(2.5-z).^2));
e=e+(r-6*10^(-32))^2;
end
end
S=(l-0.1278)^2+e
if S<li
li=S
x11=x1,y11=y1, x12=x2,y12=y2, x13=x3,y13=y3, x14=x4,y14=y4,
en4
en4
en4
disp(['x11=',num2str(x11),' ','y11=',num2str(y11),' ','x12=',num2str(x12),' ','y12=',num2str(y12),' ','x13=',num2str(x13),' ','y13=',num2str(y13),' ','x14=',num2str(x14),' ','y14=',num2str(y14)])
li