Dymola翻译后的评估参数更改

发布于 2025-01-22 20:43:47 字数 1156 浏览 3 评论 0 原文

我刚开始从Dymola和Modelica开始。 我从Modelica库的某些部分制作了一个小型模型。 该模型由“ DynamiCpipe”,“ MassFlowsource_T”,“固定式布基”和在给定时间增加质量流量的步骤组成。 我的目标是改变管道的直径和长度,看看质量流稳定所需的时间。

我写了一个小脚本,以改变直径和管道的长度,然后将质量流写入.CSV文件。

openModel("C:\Dymola\Modelica_Rohrmodel.mo")
translateModel("Modelica_Rohrmodel");

for j in 0.0 : 0.1 : 1 loop
  
  pipe.diameter = j;
  
  for i in 0 : 5 : 100 loop
    
    pipe.length = i;
    
    simulate();
    
    fileName="Modelica_Rohrmodel.mat";
    
    n=readTrajectorySize(fileName);
    
    names={"boundary.ports[1].m_flow"};
    
    traj=readTrajectory(fileName,names,n);
    
    traj_transposed=transpose(traj);
    
    CSVfile="Massflow"+String(j)+"_"+String(i)+".csv";
    
    DataFiles.writeCSVmatrix(CSVfile, names, traj_transposed);
    
  end for;
end for;

剧本清真寺有效,但我得到了: 警告:设置Pipe.lenght对模型没有影响。 翻译后,您只能设置字面的起始价值和未评估的参数。

我已经尝试将注释更改为评估= false,但失败了。

我找到了这个解决方案,但我不知道如何将其应用于我的问题。

i'am just getting started with Dymola and Modelica in general.
I've made a small model from parts of the Modelica library.
The model consists of the "DynamicPipe", the "MassFlowSource_T", the "FixedBoundary" and a Step to increase the mass flow at a given time.
My goal is to vary the diameter and the length of the pipe and see how long it takes for the mass flow to stabilize.

I've written a small script to vary the diameter and the length of the pipe an write the mass flow to a .csv file.

openModel("C:\Dymola\Modelica_Rohrmodel.mo")
translateModel("Modelica_Rohrmodel");

for j in 0.0 : 0.1 : 1 loop
  
  pipe.diameter = j;
  
  for i in 0 : 5 : 100 loop
    
    pipe.length = i;
    
    simulate();
    
    fileName="Modelica_Rohrmodel.mat";
    
    n=readTrajectorySize(fileName);
    
    names={"boundary.ports[1].m_flow"};
    
    traj=readTrajectory(fileName,names,n);
    
    traj_transposed=transpose(traj);
    
    CSVfile="Massflow"+String(j)+"_"+String(i)+".csv";
    
    DataFiles.writeCSVmatrix(CSVfile, names, traj_transposed);
    
  end for;
end for;

The script moslty works, but i get:
Warning: setting pipe.lenght has no effect in model.
After translation you can only set literal start-values and non-evaluated parameters.

I've already tried to change the annotation to Evaluate=false, but failed.

https://www.claytex.com/blog/methods/modifying-evaluated-parameters-in-multiple-simulations/
I found this solution, but I don't know how to apply it to my problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迎风吟唱 2025-01-29 20:43:47

首先要检查的东西:您的仿真设置转换选项卡中的前两个框是未选中的,正确吗?如果没有,请取消选中它们,然后重试。

顺便说一句:这对应于 evaluate = false; and advedical.evaluatealSotop = false; 来自脚本。

鉴于您的参数未通过上述设置来评估您的参数,因此Dymola可能会出于多种原因来评估 pipe.length.length 。鉴于它是一个长度而不是结构性参数,这对我来说并没有很多意义,但是如果没有模型,这很难判断。

即使在需要变化的评估参数的情况下,也可能进行的事情,正在为每个模拟使用更改的参数重新翻译模型。这将需要额外的时间(尤其是如果模拟与模拟相比,仿真很快),但这是唯一的选择。这意味着您需要将 translatemodel(“ modelica_rohrmodel”); 转移到循环中,然后将其扩展到 translatemodel(“ modelica_rohrmodel(pipe.length =“+realString(i)) );

这有点蛮力,但应该起作用...

First something to check: The first two boxes in your simulation setup's Translation tab are unchecked, correct? If not, uncheck them and try again.
Simulation Setup
BTW: This corresponds to Evaluate = false; and Advanced.EvaluateAlsoTop = false; from scripts.

Given your parameters are not evaluated by the above setting, it is possible that Dymola decides that it needs to evaluate pipe.length for multiple reasons. It does not make a lot of sense to me, given it is a length and not a structural parameter, but this is difficult to judge without having the model.

Something that is possible even with evaluated parameter which needs to be varied, is re-translating the model for every simulation with changed parameters. This will take additional time (especially if the simulation is quick compared to the simulation), but is the only option then. This would mean you need to move translateModel("Modelica_Rohrmodel"); into the loop and extend it to translateModel("Modelica_Rohrmodel(pipe.length="+realString(i)+")");

This is a bit brute force, but should work...

肤浅与狂妄 2025-01-29 20:43:47

我认为,与使用dymola使用脚本更改管道直径和长度相比,使用Dymola的长度是使用“扫描参数”,如果是最近下载,则应该在Dymola中使用。

https:// .claytex.com/tech-blog/how-to-to-a-a-a-a-a-a-a-pare-s-s-weep-in-in-dymola/

I think what would be easier than using a script to change pipe diameter and length for each simulation with dymola is to use "Sweep Parameters" which should be available in your Dymola if it's a recent download.

https://www.claytex.com/tech-blog/how-to-easily-run-a-parameter-sweep-in-dymola/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文