Cancel
Showing results for 
Search instead for 
Did you mean: 

ending the simulation

Builder
Builder

I am using various parts in the source in sequence  along with shift calender and generators which i have to end by a method in the drain when the last part exits the drain.but i have a problem now.i dont know which part is going to be the last mu to exit hence i cannot write a method to terminate the eventcontroller.what could be the way to automatically find the last mu in the model and end the simulation???

8 REPLIES

Re: ending the simulation

Siemens Phenom Siemens Phenom
Siemens Phenom
In the entrancectrl of the drain (or the destructor method of the @) you could check whether
- frame.nummu=1 or
- @.class.numchildren=1

Regards

Sent from a mobile device!

-----------------
Siemens Industry Software GmbH & Co. KG; Anschrift: Franz-Geuer-Str. 10, 50823 Köln;
Kommanditgesellschaft: Sitz der Gesellschaft: Köln; Registergericht: Amtsgericht Köln, HRA 28227;
Geschäftsführung und persönlich haftender Gesellschafter: Siemens Industry Software Management GmbH;
Geschäftsführer: Urban August, Daniel Trebes; Sitz der Gesellschaft: Köln; Registergericht: Amtsgericht Köln, HRB 70858

Regards

Always consider using the AttributeExplorer!

Re: ending the simulation

Builder
Builder

its not working .There are 20 different parts with different name and class in source.i am using the method as

 

is
do
 if 
    frame.nummu=1 then
  eventController.end:=eventController.simTime+0.001;
 end;
end;

 

but instead of ending the simulation after last part.the model keep running forever

??

Re: ending the simulation

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Hi K_parashar,

 

Where do you call the code?

 

The code you have written looks fine but it might be the condition is never true.

 

It could be that when the last MU enters the source (and triggers the method) that there are other MUs in the model which have not exited. Therefore when the last MU enters the source Frame.nummu > 1 and the event controller doesn't stop.

 

You could therefore put similar code in all of your objects and when it becomes true somewhere in the model the model will stop. However you will need to ensure that the code doesn't call when the first MU enters the system as the code would then stop the model before it got going.

 

Or you could just place the code in the drain(s) and the code should work fine but you wouldn't know where the MU was in the model when it became the last MU.

 

At the moment I can't think of a more elegant solution but someone here might come up with one. Have attached simple model showing the model stopping

 

You a probably aware of this but you can also use EventController.Stop which will stop the model straightaway instead of EventController.End

 

Ollie

 

 

 

 

Oliver MacFarlane
Simulation Engineer
web: www.simsol.co.uk
e-mail: oliver.macfarlane@simsol.co.uk

Re: ending the simulation

Builder
Builder

hi Macfaro

i am using workers in the models.are workers also counted in Nummu.when i check the MU by print command.it gives me 3 but there are no mus in the frame but only 3 workers.how can i deal with this??

Re: ending the simulation

Solution Partner Genius Solution Partner Genius
Solution Partner Genius

Didn't know that workers counted as MUs myself. Makes sense as they are Moving units suppose

 

To solve your problem you should use Broker.MediatedCapacity in your code as this will get the numbers of workers the broker(s) has brokered.

 

Your if statement would therefore read:

 

If frame.numMu - Broker.MediatedCapacity = 1 then

        EventController.Stop;

End;

 

If you have multiple brokers then you will need to add them to your code as well

 

Ollie

Oliver MacFarlane
Simulation Engineer
web: www.simsol.co.uk
e-mail: oliver.macfarlane@simsol.co.uk

Re: ending the simulation

Siemens Phenom Siemens Phenom
Siemens Phenom

You could also use the 'NumChildren' method of your MU classes to count the MUs in your simulation.

E.g.:

 

.MUs.Entitiy.NumChildren + .MUs.Container.NumChildren

 

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: ending the simulation

Builder
Builder

hi Ralf

 

the problem is i am using various container with different name and class and which container exits the drain last i cant predict .So in the method i cannot specify after whihc container the model has to stop.hence i was trying to find a way so that the model can identify the last Container in the frame irrespective of class.??

Re: ending the simulation

Siemens Phenom Siemens Phenom
Siemens Phenom

The method 'NumChildren' gives you the number of all the existing instances of your MU classes.

 

So if you create the sum of this value over all used MU classes you get the number of MUs still in your system.

(One important point is that there are no instances in other frames outside of your current simulation root.)

 

Regards,

Ralf
------------------------------------------------------------------------------------------------------
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.