0
votes

I am very new at Anylogic. I have a simple model, using the Fluid dynamics library: two tanks and a valve between them. The valve have to open at a rate, say X, only when the amount in the first tank, say tank_1, were twice of the amount of the second tank, say tank_2 Could you please help me with that? Regards

1

1 Answers

0
votes

You probably have more conditions on what to use with the valve depending on different things. But it's a bad idea to make something occur when then tank_1 is exactly 2 times larger than tank_2... Instead, create a boolean variable that tells you if the current situation is that tank_1 is over or below 2*tank_2. Let's call it "belowTank2". I will assume tank_1 is below 2*tank_2 in the beginning of the simulation. so belowTank2 is true.

Then you create an event that runs cyclically every second or even more often if you want and you use the following code:

if(belowTank2){
    if(tank_1.amount()>2*tank_2.amount()){
        valve.set_openRate(0.1);
        belowTank2=false;
    }   
}else{
    if(tank_1.amount()<2*tank_2.amount()){
        valve.set_openRate(0.3);
        belowTank2=true;
    }
}

So this means that whenever tank_1 surpases 2*tank_2, it will trigger the rate change on the valve. And it will trigger again a change when it's below 2*tank_2