有没有办法自动更改Modelica/Dymola中的目录?
我有以下问题: 我有超过20个不同的模型,我想一个接一个地模拟,但每次我都想更改模拟目录 现在,我在每次模拟后手动更改目录(从./ModelOne到./ModelTwo),我想知道在初始化或转换新模型时是否有方法自动更改目录 问候有没有办法自动更改Modelica/Dymola中的目录?,modelica,dymola,Modelica,Dymola,我有以下问题: 我有超过20个不同的模型,我想一个接一个地模拟,但每次我都想更改模拟目录 现在,我在每次模拟后手动更改目录(从./ModelOne到./ModelTwo),我想知道在初始化或转换新模型时是否有方法自动更改目录 问候 Nev最好的方法是写一个脚本,我认为: pathOfSave = {"E:\\work\\modelica\\SimulationResult\\Model1\\","E:\\work\\modelica\\SimulationResult\\Model2\\
Nev最好的方法是写一个脚本,我认为:
pathOfSave = {"E:\\work\\modelica\\SimulationResult\\Model1\\","E:\\work\\modelica\\SimulationResult\\Model2\\"};
nbSim = 2;
pathOfMod = { "MyModel.",
"MyModel.};
modelsToSimulate = { ""Model1" ,
"Model2"};
//If equdistant=true: ensure that the same number of data points is written in all result files
//store variables at events is disabled.
experimentSetupOutput(equdistant=false, events=false);
//Keep in the plot memory the last nbSim results
experimentSetupOutput(equdistant=false, events=false);
for i in 1:nbSim loop
//delete the result file if it already exists
Modelica.Utilities.Files.removeFile(pathOfSave + modelsToSimulate[i]);
//translate models
translateModel(pathOfMod[i]+modelsToSimulate[i]);
// simulate
simulateModel(
pathOfMod[i]+modelsToSimulate[i],
method="dassl",
stopTime=186350,
numberOfIntervals=nbOfPoi,
resultFile=pathOfSave + modelsToSimulate[i]);
end for;
最好的方法是写一个脚本,我认为:
pathOfSave = {"E:\\work\\modelica\\SimulationResult\\Model1\\","E:\\work\\modelica\\SimulationResult\\Model2\\"};
nbSim = 2;
pathOfMod = { "MyModel.",
"MyModel.};
modelsToSimulate = { ""Model1" ,
"Model2"};
//If equdistant=true: ensure that the same number of data points is written in all result files
//store variables at events is disabled.
experimentSetupOutput(equdistant=false, events=false);
//Keep in the plot memory the last nbSim results
experimentSetupOutput(equdistant=false, events=false);
for i in 1:nbSim loop
//delete the result file if it already exists
Modelica.Utilities.Files.removeFile(pathOfSave + modelsToSimulate[i]);
//translate models
translateModel(pathOfMod[i]+modelsToSimulate[i]);
// simulate
simulateModel(
pathOfMod[i]+modelsToSimulate[i],
method="dassl",
stopTime=186350,
numberOfIntervals=nbOfPoi,
resultFile=pathOfSave + modelsToSimulate[i]);
end for;
如果希望将命令
cd(“mynewpath”)
附加到模型,也可以将其放在初始算法部分
model example
Real variable;
protected
parameter String currDir = Modelica.Utilities.System.getWorkDirectory();
initial algorithm
cd("C:\\Users\\xxx\\Documents\\Dymola\\MyModelFolder");
equation
variable = time;
when terminal() then
cd(currDir);
end when;
end example;
在任何情况下,您都可以在手册中的“内置命令”部分找到dymola的所有命令
我希望这有帮助,
Marco如果希望将命令附加到模型,也可以将命令
cd(“mynewpath”)
放在初始算法部分
model example
Real variable;
protected
parameter String currDir = Modelica.Utilities.System.getWorkDirectory();
initial algorithm
cd("C:\\Users\\xxx\\Documents\\Dymola\\MyModelFolder");
equation
variable = time;
when terminal() then
cd(currDir);
end when;
end example;
在任何情况下,您都可以在手册中的“内置命令”部分找到dymola的所有命令
我希望这有帮助,
马可谢谢你的帮助,非常感谢!没有时间提前回答,对不起。谢谢你的帮助,非常感谢!没有时间提前回答,对不起。谢谢你的帮助,非常感谢!没有时间提前回答,对不起。谢谢你的帮助,非常感谢!没时间早回答,对不起。