Skip to content
Preview.ctl@modelscript/nmtran 10 diagnostic rules
Parser WASM GLR
Diagnostics 10 rules
DAE Arena Lowering
Simulation Native Solvers
Projections Modelica, DAE
Live ExampleTwoCompOralPK.ctl

NONMEM NM-TRAN Two-Compartment Population PK Control Stream

Pharmacometric control stream (ADVAN4 TRANS4) with between-subject exponential random effects and proportional residual error.

Playground
Source (28 lines)
1$PROBLEM Oral Two-Compartment Population PK Analysis
2$INPUT ID TIME AMT DV MDV EVID WT CRCL
3$DATA ../data/pk_phase2.csv IGNORE=@
4$SUBROUTINES ADVAN4 TRANS4
5$PK
6  TVCL = THETA(1) * (WT / 70.0)**0.75
7  TVV2 = THETA(2) * (WT / 70.0)
8  TVQ  = THETA(3)
9  TVV3 = THETA(4)
10  TVKA = THETA(5)
11  CL   = TVCL * EXP(ETA(1))
12  V2   = TVV2 * EXP(ETA(2))
13  Q    = TVQ
14  V3   = TVV3
15  KA   = TVKA * EXP(ETA(3))
16  S2   = V2
17$ERROR
18  IPRED = F
19  Y = IPRED * (1.0 + ERR(1))
20$THETA
21  (0.1, 4.5, 25.0) ; POP_CL (L/h)
22  (1.0, 32.0, 120.0) ; POP_V2 (L)
23  (0.1, 2.8, 20.0) ; POP_Q  (L/h)
24  (5.0, 48.0, 200.0) ; POP_V3 (L)
25  (0.05, 1.1, 5.0) ; POP_KA (1/h)
26$OMEGA 0.09 0.06 0.12
27$SIGMA 0.04
28$ESTIMATION METHOD=1 INTERACTION MAXEVAL=9999 PRINT=5
NM-TRAN Compartmental PK/PD Structure
ka absorption Q distribution «compartment 1» Depot (Gut) «parameters» KA = THETA(5)*exp(ETA3) Oral bolus dose «compartment 2» Central (Plasma) «model» CL = 4.5 L/h, V2 = 32 L WT allometric 0.75 «compartment 3» Peripheral «verification» Q = 2.8 L/h, V3 = 48 L FOCE-I estimation
Drag to pan · Click % to reset

NONMEM NMTRAN Pharmacometrics & PK/PD (.ctl, .mod) ​

@modelscript/nmtran (languages/nmtran) provides native WebAssembly GLR parsing, ADVAN1–ADVAN13 compartmental pharmacokinetic/pharmacodynamic (PK/PD) solving, multi-dose (AMT, RATE, II, ADDL) exposure calculation (AUC, Cmax, Tmax, t1/2), DAEBuilder lowering, and SBML / Modelica projections for NONMEM NMTRAN clinical trial and population pharmacometrics control streams.


Supported Extensions & Standards ​

ExtensionFormatDescription
.ctlNMTRAN Control StreamNONMEM control file ($PROBLEM, $INPUT, $DATA, $SUBROUTINES, $PK, $DES, $ERROR, $THETA, $OMEGA, $SIGMA, $ESTIMATION)
.modPsN / NONMEM ModelPerl-speaks-NONMEM (PsN) and Pirana pharmacometric model file

Key Capabilities ​

1. Standard PREDPP Compartmental Library (ADVAN) & General ODEs ($DES) ​

  • Parses $SUBROUTINES (ADVAN1 1-compartment IV bolus, ADVAN2 1-compartment oral first-order absorption, ADVAN3/ADVAN4 2-compartment, ADVAN11/ADVAN12 3-compartment, and ADVAN6/ADVAN13 general non-linear differential equations $DES with DADT(i)).
  • Evaluates typical parameter transformations in $PK (e.g., CL = THETA(1) * EXP(ETA(1)), V = THETA(2)) and proportional/additive residual error models in $ERROR.

2. Multi-Dose Regimen Simulation & Exposure Metrics ​

  • Simulates intravenous bolus, zero-order infusion, and extravascular oral dosing regimens (II inter-dose interval, ADDL additional doses) and automatically computes clinical exposure metrics:AUC0→t=∫0tCp(τ)dτ,t1/2=ln⁡2ke,Cmax,Tmax

3. DAE Lowering & Modelica / SBML Projection ​

  • Lowers PK/PD compartmental differential equations into @modelscript/runtime's DAEBuilder arena and projects them into Modelica 3.x (nmtranToModelica) and SBML (nmtranToSbml).

Pre-Flight Diagnostics ​

10 rules10 error

CodeRuleSeverityMessage
M9401missing-problem-recorderrorNMTRAN control stream is missing the required '$PROBLEM' record.
M9402theta-bounds-violationerror$THETA parameter 'THETA(<thetaIndex>)' violates bounds (lower=<lower>, init=<init>, upper=<upper>).
M9403missing-des-block-for-general-advanerrorSubroutine '<advan>' requires a '$DES' differential equation block.
M9404undefined-theta-referenceerrorBlock references 'THETA(<thetaIndex>)' beyond the number of declared '$THETA' parameters ('<maxTheta>').
M9405undefined-eta-referenceerrorBlock references 'ETA(<etaIndex>)' beyond the dimension of declared '$OMEGA' variance entries ('<maxOmega>').
M9406non-positive-omega-varianceerror$OMEGA diagonal variance entry 'OMEGA(<omegaIndex>)' must be positive (> 0) unless FIXED to 0 (got '<variance>').
M9407compartment-index-out-of-boundserrorCompartment reference '<cmtIndex>' exceeds declared compartment count ('<maxCmt>').
M9408missing-error-prediction-yerror$ERROR block does not define the required dependent prediction variable 'Y'.
M9409missing-required-trans-parametererrorSubroutine '<advan>' with '<trans>' requires pharmacokinetic parameter '<paramName>' in '$PK'.
M9410negative-dosing-amounterrorDosing record specifies a negative '<field>' value ('<value>').

Generated from languages/nmtran/src/errors.ts. All languages →


CLI Usage ​

bash
# Validate THETA bounds, OMEGA/SIGMA variance positivity, and ADVAN parametrization
msx lint TwoCompOralPK.ctl

# Parse and inspect NMTRAN control stream blocks
msx parse TwoCompOralPK.ctl

Open-Core under the GNU AGPL v3 License; Enterprise Edition (ee/) under the ModelScript Enterprise License. • Pricing • Trademark Policy