Your problem sounds like a deadlock issue to me. The way I’m reading your description, both models require data from one-another to perform the first timestep. In this situation, one of the models has to guess an answer to give to the other.
From your result, it seems as though Bucket 1 is being forced to guess a Q to pass to Bucket 2 and it will do this based on the last value for Q that it used. As your model has just finished initialising, this Q will be 0.0m3 unless you pass in a different initial value through the .omi file.
One possible solution springs to mind - could you try to move the trigger onto the other model (i.e. if Bucket 1 at present, put it on Bucket 2)? This should mean the ‘other’ model will now have to guess a water level to provide Bucket 1, rather than it guesing an exchange volume. As you have presumably set this water level through the .omi file, it should mean that sensible data gets passed straight away.
However, if you have a one-way linked model in the composition then this will be set as the trigger (writercsv, for example). You might be able to force the models to exhange in a different order by connecting them in the reverse order to how you're doing it presently. If this doesn't work, you will need to find another way of getting Bucket 2 to guess an exchange water level - perhaps starting this model a timestep earlier (in the .xml file) would help achieve this, as it will be forced to move first?
But you're absolutely right - as you start to add more models into the composition, things will get increasingly complicated - the choice of your trigger will become increasingly important, potentially dictating how your models need to work.
Hope this helps, but let me know if not.
Posted: 21 June 2010 10:42
Subject: Initialisation Problem
I have wrapped a simple model that passes water between 2 buckets via a tube, using 2 steps:
- The Start Bucket takes the head from the End Bucket, calculates a volume to pass on, and a new head for itself
- The End Bucket accepts a volume and adjusts its head accordingly
Under initialisation, the Start Bucket runs OK, and takes the head from the End Bucket and calculates a volume to pass on. However, when the End Bucket initialises, the volume from the Start Bucket does get passed and a zero is used. The models behave correctly for subsequent time-steps, but there is an water imbalance due to this first run.
I have checked that the order of initialisation is correct, and the only way i can get round the problem is to assign a 'volume out' for the Start Bucket in the initialise section of the code. This is not a problem under this simple interaction, as the vol change can be calculated manually. It will be a problem when we add more buckets!
Any ideas how to get round this?