.. _nonmem_advan_to_popy:
    
Nonmem Advan1,2,3,4,11,12 to |popy| analytic compartment models
#################################################################

:numref:`table_analytic_ode_conv` shows how to convert each |nonmem| inbuilt ADVAN analytic functions to |popy| equivalents.

See :ref:`$subroutines_advan_anal` for info on |nonmem| :ref:`$subroutines` section. 

Note to use the analytic compartment models in |popy| you should always set |ode_solver| as follows:-

.. code-block:: pyml

    ODE_SOLVER: {ANALYTIC:{}}
    
For more information on |popy| analytic functions see :ref:`cmp_funcs`.
    
.. _table_analytic_ode_conv:

.. list-table:: Nonmem to |popy| Analytic ODEs
    :header-rows: 1

    * - |nonmem|
      - |popy|
      - Parameters
          
    * - :ref:`ADVAN1<advan1>`
      - :ref:`@iv_one_cmp_k`
      - dose/KE
      
    * - :ref:`ADVAN1 TRANS2<advan1_trans2>`
      - :ref:`@iv_one_cmp_cl`
      - dose/CL/V
      
    * - :ref:`ADVAN2<advan2>`
      - :ref:`@dep_one_cmp_k`
      - dose/KA/KE
     
    * - :ref:`ADVAN2 TRANS2<advan2_trans2>`
      - :ref:`@dep_one_cmp_cl`
      - dose/KA/CL/V
      
    * - :ref:`ADVAN3<advan3>`
      - :ref:`@iv_two_cmp_k`
      - dose/KE/K12/K21
      
    * - :ref:`ADVAN3 TRANS4<advan3_trans4>` 
      - :ref:`@iv_two_cmp_cl`
      - dose/KA/CL/V1/Q/V2
      
    * - :ref:`ADVAN4<advan4>`
      - :ref:`@dep_two_cmp_k`
      - dose/KA/KE/K12/K21
      
    * - :ref:`ADVAN4 TRANS4<advan4_trans4>`
      - :ref:`@dep_two_cmp_cl`
      - dose/KA/CL/V1/Q/V2
      
    * - :ref:`ADVAN11<advan11>`
      - :ref:`@iv_three_cmp_k`
      - dose/KE/K12/K21/K13/K31
      
    * - :ref:`ADVAN11 TRANS4<advan11_trans4>`
      - :ref:`@iv_three_cmp_cl`
      - dose/CL/V1/Q2/V2/Q3/V3
      
    * - :ref:`ADVAN12<advan12>`
      - :ref:`@dep_three_cmp_k`
      - dose/KA/KE/K12/K21/K13/K31
     
    * - :ref:`ADVAN12 TRANS4<advan12_trans4>`
      - :ref:`@dep_three_cmp_cl`
      - dose/KA/CL/V1/Q2/V2/Q3/V3
      
.. _advan1:
    
ADVAN1
============
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN1 
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[CEN] = @iv_one_cmp_k{dose: @bolus{amt:c[AMT]}, KE: m[KE]}
        
See :ref:`@iv_one_cmp_k`.
        

.. _advan1_trans2:
    
ADVAN1 TRANS2
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN1 TRAN2 
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[CEN] = @iv_one_cmp_cl{dose: @bolus{amt:c[AMT]}, CL: m[CL], V: m[V]}
        
See :ref:`@iv_one_cmp_cl`.
        

.. _advan2:
    
ADVAN2
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN2
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[DEP,CEN] = @dep_one_cmp_k{dose: @bolus{amt:c[AMT]}, KA: m[KA], KE: m[KE]}
        
See :ref:`@dep_one_cmp_k`.


.. _advan2_trans2:
    
ADVAN2 TRANS2
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN2 TRAN2 
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[DEP,CEN] = @dep_one_cmp_cl{
            dose: @bolus{amt:c[AMT]}, 
            KA: m[KA], CL: m[CL], V: m[V]
        }
        
See :ref:`@dep_one_cmp_cl`.
        
.. _advan3:
    
ADVAN3
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN3
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[CEN,PERI] = @iv_two_cmp_k{
            dose: @bolus{amt:c[AMT]}, 
            KE: m[KE], K12: m[K12], K21: m[K21]}
    
See :ref:`@iv_two_cmp_k`.


.. _advan3_trans4:
    
ADVAN3 TRANS4
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN3 TRANS4
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[CEN,PERI] = @iv_two_cmp_cl{
            dose: @bolus{amt:c[AMT]}, 
            CL: m[CL], V1: m[V1], Q: m[Q], V2: m[V2]}

See :ref:`@iv_two_cmp_cl`.
            
.. _advan4:
    
ADVAN4
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN4
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[DEP,CEN,PERI] = @dep_two_cmp_k{
            dose: @bolus{amt:c[AMT]}, 
            KA: m[KA], KE: m[KE], K12: m[K12], K21: m[K21]}
    
See :ref:`@dep_two_cmp_k`.


.. _advan4_trans4:
    
ADVAN4 TRANS4
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN4 TRANS4
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[DEP,CEN,PERI] = @dep_two_cmp_cl{
            dose: @bolus{amt:c[AMT]}, 
            KA: m[KA], CL: m[CL], V1: m[V1], 
            Q: m[Q], V2: m[V2]}

See :ref:`@dep_two_cmp_cl`.

.. _advan11:
    
ADVAN11
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN11
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[CEN,PERI1,PERI2] = @iv_three_cmp_k{
            dose: @bolus{amt:c[AMT]}, 
            KE: m[KE], K12: m[K12], K21: m[K21], 
            K13: m[K13], K31: m[K31]}
    
See :ref:`@iv_three_cmp_k`.

.. _advan11_trans4:
    
ADVAN11 TRANS4
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN11 TRANS4
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[CEN,PERI1,PERI2] = @iv_three_cmp_cl{
            dose: @bolus{amt:c[AMT]}, 
            CL: m[CL], V1: m[V1], Q2: m[Q2], 
            V2: m[V2], Q3: m[Q3], V3: m[V3]}
    
See :ref:`@iv_three_cmp_cl`.

.. _advan12:
    
ADVAN12
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN12
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[DEP,CEN,PERI1,PERI2] = @dep_three_cmp_k{
            dose: @bolus{amt:c[AMT]}, 
            KA: m[KA], KE: m[KE], 
            K12: m[K12], K21: m[K21], 
            K13: m[K13], K31: m[K31]}
    
See :ref:`@dep_three_cmp_k`.


.. _advan12_trans4:
    
ADVAN12 TRANS4
====================
    
In |nonmem|:-

.. code-block:: none

    $SUBROUTINES  ADVAN12 TRANS4
    
Equivalent |popy| |derivatives| section:-

.. code-block:: pyml

    DERIVATIVES: |
        s[DEP,CEN,PERI1,PERI2] = @dep_three_cmp_cl{
            dose: @bolus{amt:c[AMT]}, 
            KA: m[KA], 
            CL: m[CL], V1: m[V1], 
            Q2: m[Q2], V2: m[V2], 
            Q3: m[Q3], V3: m[V3]}
    
See :ref:`@dep_three_cmp_cl`.
