# A timing issue in the differential equation system

**URL:** <https://forum.certara.com/t/a-timing-issue-in-the-differential-equation-system/2246>\
**Category:** Modelling and Simulation\
**Created:** [December 6, 2010, 5:26pm UTC](https://forum.certara.com/t/a-timing-issue-in-the-differential-equation-system/2246 "2010-12-06T17:26:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshen](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@jshen](https://forum.certara.com/u/jshen)\
**Post date:** [December 6, 2010, 5:26pm UTC](https://forum.certara.com/t/a-timing-issue-in-the-differential-equation-system/2246/1 "2010-12-06T17:26:02Z")

</div>

Hello, Hope I am not asking too many questions. Here is one more. I want to do some user-defined calculation in differential equation system. Here is an example: calculate observed Cmax and model predicted Cmax Originally, I have some code: CC=DTA(7) IF CC\>Cm\_OB THEN Cm\_OB=CC Cm\_Mod=Z(1)/Vc ENDIF DTA(7) is the column 7, where the concentration data is. After the program reads through all the data, Cm\_OB is supposed to give me observed Cmax and Cm\_Mod gives me the model predicted Concentration at the same time as the observd Cmax occurs. However I found Cm\_Mod was not at the same time as the Cm\_OB, which is assigned by CC. I guess what happens is when CC reads a record, say at observed time 0.5 hour, the differential system has to start from zero. When Cm\_OB=CC is executed, the system is still at somewhere between 0 and 0.5 hour, so Cm\_Mod is the model predicted concentration sometime earlier than 0.5 hour. My question is how I can synchronize Cm\_OB and Cm\_Mod. Thanks. Jun

---

<div class="post-metadata">

**Author:** ![ana.henry](https://sea1.discourse-cdn.com/certara/user_avatar/forum.certara.com/ana.henry/32/2578_2.png) [@ana.henry](https://forum.certara.com/u/ana.henry)\
**Post date:** [December 10, 2010, 9:20pm UTC](https://forum.certara.com/t/a-timing-issue-in-the-differential-equation-system/2246/2 "2010-12-10T21:20:26Z")

</div>

Not sure this would help. Initialize dta(3) to zero and make sire the first obs is t=0 Then use the code below and it will replace dta(3) with Cmax The final cumulative Cmax will be on the output summary table – the code below was added to PK3 from Dan Weiner’s PK/PD book Model COMM NCON 1 NPAR 3 PNAM ‘VF’,‘Tabs’,‘Ke’ NFUN 1 END TEMP T = X DOSE = CON(1) FINF = DOSE/Tabs END transform if x=0 then Cmax = y endif if x\>0 and Cmax \< y then Cmax = y endif dta(3)=Cmax end FUNC1 F = 0.0 IF T \<= Tabs THEN F =(FINF/(Ke_VF))_(1. - DEXP(-Ke_T)) ENDIF IF T \> Tabs THEN F=(FINF/(Ke_VF))_(1.-DEXP(-Ke_Tabs))_DEXP(-Ke_(T-Tabs)) ENDIF END EOM ------------ end ------------ Column3 is the first column below on the summary table Cmax t Cp 0 0 0 0.0000 0.0000 0.0000 0.0000 1.0000 Missing Missing 10 0.5 10 0.5000 10.0000 20.3550 -10.3550 1.0000 1.3144 -1.8006 46 1 46 1.0000 46.0000 36.5204 9.4796 1.0000 2.0136 1.7097 56 1.5 56 1.5000 56.0000 49.3586 6.6414 1.0000 2.3729 1.2297 56 2 56 2.0000 56.0000 59.5544 -3.5544 1.0000 2.5967 -0.6711 66 3 66 3.0000 66.0000 74.0824 -8.0824 1.0000 3.1070 -1.6118 87 4 87 4.0000 87.0000 83.2454 3.7546 1.0000 3.8650 0.8425 87 5 69 5.0000 69.0000 69.3519 -0.3519 1.0000 5.2864 -0.1344 87 6 45 6.0000 45.0000 43.7414 1.2586 1.0000 3.0439 0.2491 87 7 29 7.0000 29.0000 27.5885 1.4115 1.0000 2.8880 0.2744 87 8 15 8.0000 15.0000 17.4005 -2.4005 1.0000 2.7040 -0.4579 87 9 10 9.0000 10.0000 10.9748 -0.9748 1.0000 2.3126 -0.1796 87 10 9 10.0000 9.0000 6.9220 2.0780 1.0000 1.8537 0.3711 \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
