exampleSimulation2脚本

这段代码是一个用于运行温室环境模拟的MATLAB脚本,使用了GreenLight模型来模拟温室内的环境参数(如温度、湿度、CO2浓度等)以及作物的生长情况。代码通过预定义的输入和设置来运行模拟,并绘制了多个输出结果的图表。以下是代码的详细解释:


1. 设置文件路径

matlab
复制
currentFile = mfilename('fullpath');
currentFolder = fileparts(currentFile);
dataFolder = strrep(currentFolder, '\Code\runScenarios', '\Code\inputs\energyPlus\data\');
outputFolder = strrep(currentFolder, '\Code\runScenarios', '\Output\');
  • mfilename('fullpath') 获取当前文件的完整路径。
  • fileparts 提取当前文件所在的文件夹路径。
  • strrep 用于替换路径中的部分字符串,生成数据文件夹和输出文件夹的路径。

2. 天气输入设置

matlab
复制
weatherInput = 'bei'; % Choose name of location, see folder inputs\energyPlus\data\
seasonLength = 1;   % season length in days
firstDay = 1;       % Beginning of season (days since January 1)
  • weatherInput 指定了天气数据文件的名称(例如 bei 表示北京的天气数据)。
  • seasonLength 设置了模拟的季节长度(1天)。
  • firstDay 设置了模拟开始的时间(从1月1日开始的第一天)。

3. 作物设置

matlab
复制
isMature = true; % Start with a mature crop, use false to start with a small crop
  • isMature 是一个布尔值,用于指定作物是否从成熟状态开始。如果设置为 false,则作物从幼苗状态开始。

4. 灯具选择

matlab
复制
lampType = 'led'; % 'led', 'hps', or 'none'
  • lampType 指定了温室中使用的灯具类型,可以是 led(LED灯)、hps(高压钠灯)或 none(无灯具)。

5. 温室结构设置

matlab
复制
p.psi = 22;                     % Mean greenhouse cover slope [°]
p.aFlr = 4e4;                   % Floor area of  [m^{2}]
p.aCov = 4.84e4;                % Surface of the cover including side walls [m^{2}]
p.hAir = 6.3;                   % Height of the main compartment [m]
p.hGh = 6.905;                  % Mean height of the greenhouse [m]
p.aRoof = 0.1169*4e4;           % Maximum roof ventilation area 
p.hVent = 1.3;                  % Vertical dimension of single ventilation opening [m]
p.cDgh = 0.75;                  % Ventilation discharge coefficient [-]          
p.lPipe = 1.25;                 % Length of pipe rail system [m m^{-2}]
p.phiExtCo2 = 7.2e4*4e4/1.4e4;  % Capacity of CO2 injection for the entire greenhouse [mg s^{-1}] 
p.pBoil = 300*p.aFlr;           % Capacity of boiler for the entire greenhouse [W]
  • 这些参数定义了温室的结构和物理特性,例如温室的高度、面积、通风面积、CO2注入能力等。

6. 控制设置

matlab
复制
p.co2SpDay = 1000;          % CO2 setpoint during the light period [ppm]
p.tSpNight = 18.5;          % temperature set point dark period [°C]
p.tSpDay = 19.5;            % temperature set point light period [°C]
p.rhMax = 87;               % maximum relative humidity [%]
p.ventHeatPband = 4;        % P-band for ventilation due to high temperature [°C]
p.ventRhPband = 50;         % P-band for ventilation due to high relative humidity [% humidity]
p.thScrRhPband = 10;        % P-band for screen opening due to high relative humidity [% humidity]
p.lampsOn = 0;              % time of day (in morning) to switch on lamps [h]
p.lampsOff = 18;            % time of day (in evening) to switch off lamps [h]
p.lampsOffSun = 400;        % lamps are switched off if global radiation is above this value [W m^{-2}]
p.lampRadSumLimit = 10;     % Predicted daily radiation sum from the sun where lamps are not used that day [MJ m^{-2} day^{-1}]
  • 这些参数定义了温室的控制策略,例如温度、湿度和CO2的设定值,灯具的开关时间,以及通风和遮阳的控制逻辑。

7. 运行模拟

matlab
复制
tic;
filename = ''; % add file name for saving file
if ~isempty(filename)
    filename = [outputFolder filename];
end
season = cutEnergyPlusData(firstDay, seasonLength, [dataFolder weatherInput 'EnergyPlus.mat']);
gl = runGreenLight(lampType, season, filename, paramNames, paramVals, isMature);
toc;
  • tictoc 用于计时。
  • cutEnergyPlusData 函数从天气数据文件中提取指定时间段的数据。
  • runGreenLight 函数运行GreenLight模型,生成模拟结果 gl

8. 绘制输出结果

代码使用 subplot 创建了多个子图,分别绘制了以下内容:

  1. 温度和室外温度tAirtOut)。
  2. 室内外水汽压vpAirvpOut)。
  3. 室内外相对湿度rhInrhOut)。
  4. 室内外CO2浓度co2Airco2Out)。
  5. 室内外CO2浓度(ppm)co2InPpmco2Out)。
  6. 室外总辐射、PAR辐射和灯具输入iGlobrParGhSunrParGhLamp 等)。
  7. 光合有效辐射(PPFD)parJtoUmolSunzetaLampPar)。
  8. 作物同化、呼吸和生长mcAirCanmcAirBuf 等)。
  9. 作物干物质分配cFruitcStemcLeaf 等)。
  10. 果实干重和收获cFruitmcFruitHar)。

9. 时间格式化

matlab
复制
dateFormat = 'HH:00';
numticks = get(gca,'XTick');
dateticks = datenum(datenum(gl.t.label)+numticks/86400);
datestrings = datestr(dateticks,dateFormat);
xticklabels(datestrings);
  • 将X轴的时间刻度格式化为小时和分钟(HH:00)。

总结

这段代码的主要功能是:

  1. 加载天气数据和温室参数。
  2. 运行GreenLight模型,模拟温室环境和作物生长。
  3. 绘制温室环境参数(温度、湿度、CO2浓度等)和作物生长指标(干物质分配、光合作用等)的变化曲线。

通过调整输入参数(如灯具类型、温室结构、控制策略等),用户可以研究不同设置对温室环境和作物生长的影响。

这段代码定义了温室的结构和物理特性参数,这些参数用于GreenLight模型中的温室环境模拟。以下是每个参数的具体含义和单位:


1. 温室覆盖坡度

matlab
复制
p.psi = 22; % Mean greenhouse cover slope [°]
  • 含义:温室覆盖的平均坡度(倾斜角度)。
  • 单位:度(°)。
  • 作用:影响温室的光照接收和热交换。

2. 温室地板面积

matlab
复制
p.aFlr = 4e4; % Floor area of  [m^{2}]
  • 含义:温室的地板面积。
  • 单位:平方米(m²)。
  • 作用:用于计算温室的总空间和作物的种植面积。

3. 温室覆盖面积(包括侧墙)

matlab
复制
p.aCov = 4.84e4; % Surface of the cover including side walls [m^{2}]
  • 含义:温室覆盖的总面积,包括屋顶和侧墙。
  • 单位:平方米(m²)。
  • 作用:用于计算温室的热交换和光照分布。

4. 主室高度

matlab
复制
p.hAir = 6.3; % Height of the main compartment [m]
  • 含义:温室主室的高度。
  • 单位:米(m)。
  • 作用:影响温室内的空气流动和温度分布。

5. 温室平均高度

matlab
复制
p.hGh = 6.905; % Mean height of the greenhouse [m]
  • 含义:温室的平均高度。
  • 单位:米(m)。
  • 作用:用于计算温室的热容量和空气体积。

6. 最大屋顶通风面积

matlab
复制
p.aRoof = 0.1169*4e4; % Maximum roof ventilation area 
  • 含义:温室屋顶的最大通风面积。
  • 单位:平方米(m²)。
  • 作用:影响温室的通风能力和空气交换效率。

7. 单通风口的垂直尺寸

matlab
复制
p.hVent = 1.3; % Vertical dimension of single ventilation opening [m]
  • 含义:单个通风口的垂直高度。
  • 单位:米(m)。
  • 作用:用于计算通风口的空气流量。

8. 通风排放系数

matlab
复制
p.cDgh = 0.75; % Ventilation discharge coefficient [-]          
  • 含义:通风口的排放系数,表示通风效率。
  • 单位:无量纲。
  • 作用:用于计算通风口的实际空气流量。

9. 管道轨道系统长度

matlab
复制
p.lPipe = 1.25; % Length of pipe rail system [m m^{-2}]
  • 含义:每平方米地板面积的管道轨道系统长度。
  • 单位:米每平方米(m/m²)。
  • 作用:用于计算温室内的加热或冷却系统的分布。

10. CO2注入能力

matlab
复制
p.phiExtCo2 = 7.2e4*4e4/1.4e4; % Capacity of CO2 injection for the entire greenhouse [mg s^{-1}] 
  • 含义:整个温室的CO2注入能力。
  • 单位:毫克每秒(mg/s)。
  • 作用:用于模拟CO2浓度对作物光合作用的影响。

11. 锅炉容量

matlab
复制
p.pBoil = 300*p.aFlr; % Capacity of boiler for the entire greenhouse [W]
  • 含义:整个温室的锅炉加热容量。
  • 单位:瓦特(W)。
  • 作用:用于模拟温室的加热系统对温度的影响。

总结

这段代码定义了温室的结构、通风、加热和CO2注入等关键参数。这些参数用于GreenLight模型中,以模拟温室内的环境条件(如温度、湿度、CO2浓度等)以及作物的生长情况。通过调整这些参数,用户可以研究不同温室设计对环境和作物生长的影响。

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇