- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Cannot Figure Out the language
Cannot Figure Out the language
Cannot Figure Out the language
This is a really ridiculous question and I feel quite silly asking it but how do you integrate on of the functions you have defined. I am modeling Spanish Influenza and it will not let me integrate the number of incubating people...
model Influenza
// Parameters
parameter Real MortalityProb(start = 0.01);
parameter Real RecoveryTime(start = 2.5);
// In days
parameter Real MortalityTime(start = 1);
// In days
parameter Real TransmissionProb(start = 0.15);
parameter Real EncounterRate(start = 4);
// People per day
parameter Real IncubationTime(start = 2.5);
// In days
// Start variables
Real Removed(start = 0);
Real Deceased(start = 0);
Real Recovered(start = 0);
Real Infectious(start = 1000);
Real Incubating(start = 0);
Real Susceptible(start = 103267000);
Real Population;
Real R;
annotation(experiment(StartTime = 0.0, StopTime = 180.0, Tolerance = 1e-006));
equation
Population = Recovered + Infectious + Incubating + Susceptible;
R = (TransmissionProb * EncounterRate * Susceptible) / Population;
Deceased = MortalityProb * Removed;
Recovered = (1 - MortalityProb) * Removed;
der(Removed) = (MortalityProb / MortalityTime + (1 - MortalityProb) / RecoveryTime) * Infectious;
der(Infectious) = -der(Removed) + Incubating / IncubationTime;
der(Susceptible) = -R * Infectious;
der(Incubating) = -Incubating / IncubationTime + R * Infectious;
end Influenza;
The incubation equation is listed above
I would appreciate any help
Thanks
Re: Cannot Figure Out the language
Hi Loni,
I tried to simulate your model, and it simulates just fine. The Incubating variable gives a nice bell curve, which seems about right to me. Could you perhaps be a bit more specific? What do you mean with "will not let me integrate". Do you get an error message from the compiler, or do you simply not get the result you were expecting?
- perost
- 114 Posts
Re: Cannot Figure Out the language
Thank you,
I want to integrate the incubating funtion again so I can determine the total number of infected people throughout the 180 days. I tried adding this variable:
Real TotalInfected (start = 0);
And then I didnte know how to set it to integrate something that would look similar to this (only coded correctly):
TotalInfected = (1/IncubationTime)*integral(Incubating,0,180);
This is obviously incorrect I just don't know how to code the regular integral
Re: Cannot Figure Out the language
Ok, I see. Unfortunately I don't really know how to solve this problem. Perhaps saying der(TotalInfected) = Incubating / IncubationTime would work? Remember that the model is simulated for a certain number of timesteps, so saying der(TotalInfected) = Incubating should integrate the number of incubating people. I'm a bit unsure about the division with IncubationTime though.
I get about 58 million infected people though, i.e. about half the population, which doesn't seem completely unreasonable. Hopefully someone who knows what they're doing can give you some better advice.
- perost
- 114 Posts
Re: Cannot Figure Out the language
Hi Loni,
Did you try:
der(TotalInfected) = Incubating;
if you integrate both sides, you get TotalInfected = Integral(Incubating)
TotalInfected is the integral over the function Incubating, but I am not sure if that is really what you want because the end value is higher than the total population.
Isn't the maximum of Incubating the value you are looking for?
Best regards,
Rolf
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Cannot Figure Out the language