WinNonmix code
From: "Nele Plock" nplock@zedat.fu-berlin.de
Subject: [NMusers] WinNonmix code
Date: Thu, February 10, 2005 10:24 am
Dear all of you,
Im using WinNonmix for population analysis and although this is a discussion
group for NONMEM users I hope theres somebody around who can help me with my problem.
I have been trying to write a model in WinNonmix for oral dosing with zero
order input and first order elimination from the central and peripheral
compartment. Every time I try to run the model I get the error message "Unable
to calculate the first derivative matrix of the model". Changing the initials
does not help. Ive attached the code below. Can somebody tell me if there is
an error in the model? Any help would be highly appreciated!
Thanks for your help
Nele
_______________________________
Nele Plock
Freie Universitaet Berlin
Institute of Pharmacy
Dept. Clinical Pharmacy
Kelchstr. 31
D-12169 Berlin
Germany
tel: +49 (0) 30 838-50625
fax: +49 (0) 30 838-50711
email: nplock@zedat.fu-berlin.de
________________________________
The used model is as follows:
!******************************************************************************
!*
!* PK3.f90
!*
!* DESCRIPTION:
!*
!* This subroutine describes an two compartment model with zero order
!* input, first-order output, elimination from a peripheral cmt and lag time.
!*
!*
!* REQUIRED FORTRAN COMPILERS
!*
!* 1) DIGITAL VISUAL FORTRAN
!* 2) MICROSOFT FORTRAN POWERSTATION 4.0
!*
!* INPUT:
!*
!* 1) mode: index describing the type of calculation to be performed.
!*
!* mode = 2 for predicted values
!* mode = 3 for differential equations
!* mode = 4 for starting values of differential equations
!* mode = 5 for secondary parameters
!*
!* 2) p: vector containing structural model parameters, where
!*
!* p(1) = V
!* p(2) = cl
!* p(3) = ti
!* p(4) = tlag
!* p(5) = q
!* p(6) = v2
!* p(7) = cl2
!*
!* 3) con: vector containing constants requried in the model, where
!*
!* con(1) = # doses
!* con(2) = dose 1
!* con(3) = time of dose 1
!* etc.
!*
subroutine usrmod(mode, funcno, dta, f, p, dz, s, con, x, z, wt, y, objfn)
implicit none
integer mode, funcno
real*8 p(1), con(1), x, f, s(1), z(1), dz(1), dta(1), wt(1), y, objfn
real*8 v, cl, k10, t, sum, dose, auc, cmax, tmax, k0, ti, tlag, k12, k21
real*8 k20, INP, q, v2, cl2
integer nn, ndose, k, i
v = p(1)
cl = p(2)
ti = p(3)
tlag = p(4)
q = p(5)
v2 = p(6)
cl2 = p(7)
if (mode == 2) then
f = z(1)/v
else if (mode == 5) then
else if (mode == 4) then
z(1) = 0.0d0
z(2) = 0.0d0
else if (mode == 3) then
nn = idint(con(1) + 1.0d-4)
call n_dose(nn, x, con, 3, 2, ndose)
if (ndose == 0) then
f = 0.0d0
else
sum = 0.0d0
end if
k = 3
k10 = cl / v
k12 = q / v
k21 = q / v2
k20 = cl2 / v2
do i = 1, ndose
t = x - con(k)
dose = con(k-1)
k0 = dose / ti
INP = 0.0d0
if (t < ti) then
INP = k0
endif
dz(1) = INP - k10 * z(1) - k12 * z(1) + k21 * z(2)
dz(2) = k12 * z(1) - k21 * z(2) - k20 * z(2)
k = k + 2
end do
end if
contains
subroutine n_dose(nn, t, con, fst, inc, ndose)
implicit none
integer nn, fst, inc, ndose
real*8 t, con(:)
integer i, k
k = fst
do i = 1, nn
if (con(k) > t) exit
k = k + inc
end do
ndose = i - 1
end subroutine n_dose
end subroutine usrmod
_______________________________________________________