FC Coding is One step from 1st Principles to Solution!

Increased Productivity Example #5

PharmacoKinetics Simulation

A Pharmacokinetics open-two-compartment model with first order absorption into elimination from central compartment (blood cleared of drug through the liver and/or kidneys) is presented here. The body tissues utilize the drug and therefor an amount is removed by the body's filtering system, i.e. the liver and/or kidneys.

Rate of change in compartments is stated by the following differential equations:

Plasma compartment

Tissue compartment

where
K_{y} represent Rate constants; y = a, 10, 12, and 21;

A_{i} = Amount of drug at the i^{th} site: 0. Absorption site; 1. Compartment 1; and 2. Compartment 2.

This system of differential equations can be solved analytically using La Place transforms. These solutions are usually expressed in terms of drug concentrations (i.e., parameters A, B, & C). The model equation for compartment 1 is

C = - ( A + B )

where Cp(t) is the plasma concentration at time t;
and 'alpha' & 'beta' are hybrid parameters derived from K_{12},
K_{21}, K_{10}, and K_{a}.

The half-life of 'beta' is constrained to the range of three to nine years, and thus, adds the two constraints: Half_life >= 3 and <= 9 years where the Half_life = ln(2) / beta.

Relative error in curve fitting was chosen due to the huge swing in amplitude over time.

Increased Productivity Example #5
Source Code:

Calculus Program Listing:

Global All Problem Pharmaco ! -Kinetic parameters for open-two-compartment model Dimension Time( 12), Plasma( 12), Error( 12), Lows(5), Half(2) ! Observed plasma concentrations ... Oral tablet of 10 mg Data Time/0, .333, .5, .667, 1, 2, 4, 6, 8, 12, 24, 32/ ! X-Data Data Plasma/1.e-4, .657, .727, .763, .695, .51, .307, .161, ! Y-Data .135, .046, .021, .008/ ! X-Units=Hr. & Y-Units=Mcg/Ml Data Lows/ 5*0.D0/, Half/ 2*0.D0/ Npoints = 12: desiredHalflife = 1.2345 Write(1,*) ' Enter Initial Starting Value ... ' Read *, X A=X: B=X: Ka=X: Alpha=X: Beta=X ! Initial Values ! The next 'find' statement is many simulations combined into one. ! The solver 'jupiter' finds -a solution- that minimizes 'sum' Find A, B, Ka, Alpha, Beta; In Concentr; By Jupiter; With Lowers Lows; Holding Half; To Minimize Sum ! Changed problem to an Inverse Problem ... notice minimal difference. ! Takes a run or two to insure model & optimal solution. Find A, B, Ka, Alpha, Beta; In Concentr; By Jupiter; With Lowers Lows; Holding Half; To Match HalflifeError End Model Concentr ! Concentration In Compartment 1 Sum = 0 Do 10 i = 1, Npoints T = Time( i) C1 = A * Exp( - Alpha * T): C2 = B * Exp( - Beta * T): C = -(A + B) C3 = C * Exp( - Ka * T): Cp_t = C1 + C2 + C3 Error(i) = (Plasma( i) - Cp_t) / Plasma( i) Sum = Sum + Error(i)**2 10 Continue Halflife = Log( 2) / Beta: HalflifeError = desiredHalflife - Halflife Half(1) = Halflife - 3 ! 3 Years Minimum Half(2) = 9 - Halflife ! 9 Years Maximum End

This PharmacoKinetics problem is another increased productivity example do to using Calculus (level) programming.

HTML code for linking to this page:

<a
href="https://goal-driven.net/example/pharmacokinetics.html"><img
style="float:left; width:100px"
src="https://goal-driven.net/image/pharmaco-pic1.png.png"/>
<strong>PharmacoKinetics, an Inverse Problem</strong>
</a>: Know desired Half Life, Find design parameters for Half
Life. Kinetic Simulation.