3
Wolfram System Modeler에서 간격 당 최대 간격 블록을 생성합니다. Modelica - 증가가 조건을 따르지 않습니다.
내가 바로 박쥐 무한대로 실행 (10)block HighWaterMarkPerInterval
extends Modelica.Blocks.Interfaces.SISO;
protected
Integer index;
Real currentMax;
Real endTimes[1, 45] = [30812532.2, 32037805, 33265581.8, 34493233.8, 35720861.5, 36948483, 38176307.7, 39426940.6, 40654485.4, 41882212.1, 43109672.7, 44337076, 45564265.7, 46793039.6, 48045130.9, 50749960.3, 52040090.6, 53558507.7, 54814537.3, 56331978.2, 57587753.3, 59105952.9, 60362517.8, 61879307.8, 63136031.5, 64363411.4, 65590464.3, 67738027.40000001, 84725789.8, 87831338.09999999, 89030965.40000001, 90258821.8, 91486663.5, 92714210.3, 93941727.7, 95166770.3, 97283519, 99434222.90000001, 100658067.1, 102807019, 104030032.7, 106179193, 107402090, 109550214.2, 110771545.3];
algorithm
if endTimes[1, index] < time then
index := pre(index) + 1;
currentMax := 0;
else
currentMax := 10; // Constant to until I get logic working
end if;
initial algorithm
index := 0;
equation
y = currentMax;
end HighWaterMarkPerInterval;
에 인덱스 증가를 최대 값을 설정, 쉽게 설명해 할 수 있도록합니다. 나는 내 논리에 문제가 있다는 것을 알았지 만 그것을 이해할 수는 없다.
코드는 우리가 여전히 인터벌 시간에 있는지를 확인하고 다음 인터벌 시간으로 넘어갈 때 "currentMax"값을 0으로 설정합니다. 그러면 다른 블록에서 구현 한 최대 값이 재설정됩니다.
도움을 주시면 감사하겠습니다. 감사.
EDIT : 코드 섹션 양식 예.
model HighWaterMarkPerInterval
annotation(Diagram(coordinateSystem(extent = {{-148.5, -105}, {148.5, 105}}, preserveAspectRatio = true, initialScale = 0.1, grid = {5, 5})));
extends Modelica.Blocks.Interfaces.SISO;
Modelica.Blocks.Math.Max maxblock(u1 = currentMax, u2 = u);
Real flybyEnds[1, 45] = [30813151,32038322,33266015, truncated for space saving...];
Integer index;
Real currentMax;
initial equation
index = 1;
currentMax = 0;
algorithm
// When we are in the interval continually grab max block output and output currentMax
when {time>=flybyEnds[1, index-1], time <=flybyEnds[1,index]} then
currentMax := pre(maxblock.y);
y := currentMax;
end when;
// When we move to the next interval reset current max and move to the next interval
when time > flybyEnds[1, index] then
currentMax := 0;
index := pre(index) + 1;
end when;
end HighWaterMarkPerInterval;
을,하지만 난 때를 사용하여 재설정하는 방법을 알아낼 수 없습니다 기능. 그것이 올바르게 이해된다면 내가하려고하는 일을하기 위해'when-else' 명령문의 기능이 필요합니다. – user3791725
"재설정"이라는 것이 무슨 뜻인지 설명 할 수 있습니까? –
예, 죄송합니다. 'currentMax'는 매번'endTime'마다 리셋되기로되어 있습니다. 전체 시뮬레이션 동안 하이 워터 마크 대신 모든 간격에 대해 'currentMax' 값을 계산하려고합니다. 'endTimes'는 간격 종료 시간에 해당합니다. – user3791725