drux 0.3__tar.gz → 0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drux
3
- Version: 0.3
3
+ Version: 0.4
4
4
  Summary: Drux: Drug Release Analysis Framework
5
5
  Home-page: https://github.com/openscilab/drux
6
- Download-URL: https://github.com/openscilab/drux/tarball/v0.3
6
+ Download-URL: https://github.com/openscilab/drux/tarball/v0.4
7
7
  Author: Drux Development Team
8
8
  Author-email: drux@openscilab.com
9
9
  License: MIT
@@ -118,9 +118,9 @@ Drux is a Python-based framework for simulating drug release profiles using math
118
118
 
119
119
  ### PyPI
120
120
  - Check [Python Packaging User Guide](https://packaging.python.org/installing/)
121
- - Run `pip install drux==0.3`
121
+ - Run `pip install drux==0.4`
122
122
  ### Source code
123
- - Download [Version 0.3](https://github.com/openscilab/drux/archive/v0.3.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
123
+ - Download [Version 0.4](https://github.com/openscilab/drux/archive/v0.4.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
124
124
  - Run `pip install .`
125
125
 
126
126
  ## Supported Models
@@ -205,6 +205,29 @@ where:
205
205
  3. Comparative studies
206
206
  4. Vivo predictions
207
207
 
208
+ ### Hopfenberg
209
+ The Hopfenberg model describes drug release from surface-eroding polymers with a constant surface area.
210
+ It is particularly useful for modeling drug release from biodegradable polymers where the drug is uniformly distributed throughout the matrix.
211
+ According to this model, the cumulative amount of drug released at time $t$ is given by:
212
+
213
+ $$
214
+ M_t = M_{\infty} \left(1 - \left(1 - \frac{k_0t}{c_0 a_0}\right)^n\right)
215
+ $$
216
+
217
+ where:
218
+ - $M_t (mg)$ is the cumulative absolute amount of drug released at time $t
219
+ - $M_{\infty} (mg)$ is the total amount of drug released at infinite time
220
+ - $k_0 (\frac{mg}{mm^2 s})$ is the surface erosion rate constant
221
+ - $c_0 (\frac{mg}{mm^3})$ is the initial drug concentration in the polymer matrix
222
+ - $a_0 (mm)$ is the initial radius (for spheres) or half-thickness (for slabs) of the device
223
+ - $n$ is the geometry-dependent exponent (1 for slabs, 2 for cylinders, 3 for spheres)
224
+
225
+ #### Applications
226
+ 1. Biodegradable Implants
227
+ 2. Surface-eroding drug delivery systems
228
+ 3. Transdermal Patches
229
+ 4. Injectable depots
230
+
208
231
  ## Usage
209
232
  ### Zero-Order Model
210
233
  ```python
@@ -243,6 +266,17 @@ model.plot(show=True)
243
266
  ```
244
267
  <img src="https://github.com/openscilab/drux/raw/main/otherfiles/weibull_plot.png" alt="Weibull Plot">
245
268
 
269
+ ### Hopfenberg Model
270
+
271
+ ```python
272
+ from drux import HopfenbergModel
273
+ model = HopfenbergModel(M=1, k0=0.00067, c0=0.0374, a0=3.51, n=2)
274
+ model.simulate(duration=100, time_step=1)
275
+ model.plot(show=True)
276
+ ```
277
+ <img src="https://github.com/openscilab/drux/raw/main/otherfiles/hopfenberg_plot.png" alt="Hopfenberg Plot">
278
+
279
+
246
280
  ## Issues & bug reports
247
281
 
248
282
  Just fill an issue and describe it. We'll check it ASAP! or send an email to [drux@openscilab.com](mailto:drux@openscilab.com "drux@openscilab.com").
@@ -264,6 +298,9 @@ You can also join our discord server
264
298
  <blockquote>5- S. Dash, "Kinetic modeling on drug release from controlled drug delivery systems," <i>Acta Poloniae Pharmaceutica</i>, 2010.</blockquote>
265
299
  <blockquote>6- K. H. Ramteke, P. A. Dighe, A. R. Kharat, S. V. Patil, <i>Mathematical models of drug dissolution: A review</i>, <i>Sch. Acad. J. Pharm.</i>, vol. 3, no. 5, pp. 388-396, 2014.</blockquote>
266
300
  <blockquote>7- C. Corsaro, G. Neri, A. M. Mezzasalma, and E. Fazio, "Weibull modeling of controlled drug release from Ag-PMA nanosystems," <i>Polymers</i>, vol. 13, no. 17, p. 2897, 2021.</blockquote>
301
+ <blockquote>8- H. B. Hopfenberg, "Controlled release from erodible slabs, cylinders, and spheres," in <i>Controlled Release Polymeric Formulations</i>, ACS Symposium Series, vol. 33, pp. 26–32, 1976.</blockquote>
302
+ <blockquote>9- H. V. Chavda, M. S. Patel, and C. N. Patel, "Preparation and in vitro evaluation of guar gum based triple-layer matrix tablet of diclofenac sodium," <i>Research in Pharmaceutical Sciences</i>, vol. 7, no. 1, pp. 57–64, Jan. 2012.</blockquote>
303
+
267
304
 
268
305
  ## Show your support
269
306
  ### Star this repo
@@ -282,6 +319,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
282
319
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
283
320
 
284
321
  ## [Unreleased]
322
+ ## [0.4] - 2026-05-18
323
+ ### Added
324
+ - Hopfenberg model
285
325
  ## [0.3] - 2025-12-08
286
326
  ### Added
287
327
  - Weibull model
@@ -305,7 +345,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
305
345
  - Higuchi model
306
346
 
307
347
 
308
- [Unreleased]: https://github.com/openscilab/drux/compare/v0.3...dev
348
+ [Unreleased]: https://github.com/openscilab/drux/compare/v0.4...dev
349
+ [0.4]: https://github.com/openscilab/drux/compare/v0.3...v0.4
309
350
  [0.3]: https://github.com/openscilab/drux/compare/v0.2...v0.3
310
351
  [0.2]: https://github.com/openscilab/drux/compare/v0.1...v0.2
311
352
  [0.1]: https://github.com/openscilab/drux/compare/48548f0...v0.1
@@ -63,9 +63,9 @@ Drux is a Python-based framework for simulating drug release profiles using math
63
63
 
64
64
  ### PyPI
65
65
  - Check [Python Packaging User Guide](https://packaging.python.org/installing/)
66
- - Run `pip install drux==0.3`
66
+ - Run `pip install drux==0.4`
67
67
  ### Source code
68
- - Download [Version 0.3](https://github.com/openscilab/drux/archive/v0.3.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
68
+ - Download [Version 0.4](https://github.com/openscilab/drux/archive/v0.4.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
69
69
  - Run `pip install .`
70
70
 
71
71
  ## Supported Models
@@ -150,6 +150,29 @@ where:
150
150
  3. Comparative studies
151
151
  4. Vivo predictions
152
152
 
153
+ ### Hopfenberg
154
+ The Hopfenberg model describes drug release from surface-eroding polymers with a constant surface area.
155
+ It is particularly useful for modeling drug release from biodegradable polymers where the drug is uniformly distributed throughout the matrix.
156
+ According to this model, the cumulative amount of drug released at time $t$ is given by:
157
+
158
+ $$
159
+ M_t = M_{\infty} \left(1 - \left(1 - \frac{k_0t}{c_0 a_0}\right)^n\right)
160
+ $$
161
+
162
+ where:
163
+ - $M_t (mg)$ is the cumulative absolute amount of drug released at time $t
164
+ - $M_{\infty} (mg)$ is the total amount of drug released at infinite time
165
+ - $k_0 (\frac{mg}{mm^2 s})$ is the surface erosion rate constant
166
+ - $c_0 (\frac{mg}{mm^3})$ is the initial drug concentration in the polymer matrix
167
+ - $a_0 (mm)$ is the initial radius (for spheres) or half-thickness (for slabs) of the device
168
+ - $n$ is the geometry-dependent exponent (1 for slabs, 2 for cylinders, 3 for spheres)
169
+
170
+ #### Applications
171
+ 1. Biodegradable Implants
172
+ 2. Surface-eroding drug delivery systems
173
+ 3. Transdermal Patches
174
+ 4. Injectable depots
175
+
153
176
  ## Usage
154
177
  ### Zero-Order Model
155
178
  ```python
@@ -188,6 +211,17 @@ model.plot(show=True)
188
211
  ```
189
212
  <img src="https://github.com/openscilab/drux/raw/main/otherfiles/weibull_plot.png" alt="Weibull Plot">
190
213
 
214
+ ### Hopfenberg Model
215
+
216
+ ```python
217
+ from drux import HopfenbergModel
218
+ model = HopfenbergModel(M=1, k0=0.00067, c0=0.0374, a0=3.51, n=2)
219
+ model.simulate(duration=100, time_step=1)
220
+ model.plot(show=True)
221
+ ```
222
+ <img src="https://github.com/openscilab/drux/raw/main/otherfiles/hopfenberg_plot.png" alt="Hopfenberg Plot">
223
+
224
+
191
225
  ## Issues & bug reports
192
226
 
193
227
  Just fill an issue and describe it. We'll check it ASAP! or send an email to [drux@openscilab.com](mailto:drux@openscilab.com "drux@openscilab.com").
@@ -209,6 +243,9 @@ You can also join our discord server
209
243
  <blockquote>5- S. Dash, "Kinetic modeling on drug release from controlled drug delivery systems," <i>Acta Poloniae Pharmaceutica</i>, 2010.</blockquote>
210
244
  <blockquote>6- K. H. Ramteke, P. A. Dighe, A. R. Kharat, S. V. Patil, <i>Mathematical models of drug dissolution: A review</i>, <i>Sch. Acad. J. Pharm.</i>, vol. 3, no. 5, pp. 388-396, 2014.</blockquote>
211
245
  <blockquote>7- C. Corsaro, G. Neri, A. M. Mezzasalma, and E. Fazio, "Weibull modeling of controlled drug release from Ag-PMA nanosystems," <i>Polymers</i>, vol. 13, no. 17, p. 2897, 2021.</blockquote>
246
+ <blockquote>8- H. B. Hopfenberg, "Controlled release from erodible slabs, cylinders, and spheres," in <i>Controlled Release Polymeric Formulations</i>, ACS Symposium Series, vol. 33, pp. 26–32, 1976.</blockquote>
247
+ <blockquote>9- H. V. Chavda, M. S. Patel, and C. N. Patel, "Preparation and in vitro evaluation of guar gum based triple-layer matrix tablet of diclofenac sodium," <i>Research in Pharmaceutical Sciences</i>, vol. 7, no. 1, pp. 57–64, Jan. 2012.</blockquote>
248
+
212
249
 
213
250
  ## Show your support
214
251
  ### Star this repo
@@ -6,5 +6,6 @@ from .higuchi import HiguchiModel, HiguchiParameters
6
6
  from .zero_order import ZeroOrderModel, ZeroOrderParameters
7
7
  from .first_order import FirstOrderModel, FirstOrderParameters
8
8
  from .weibull import WeibullModel, WeibullParameters
9
+ from .hopfenberg import HopfenbergModel, HopfenbergParameters
9
10
 
10
11
  __version__ = DRUX_VERSION
@@ -0,0 +1,92 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Drux Hopfenberg model implementation."""
3
+
4
+ from .base_model import DrugReleaseModel
5
+ from .messages import (
6
+ ERROR_INVALID_EROSION_CONSTANT,
7
+ ERROR_INVALID_INITIAL_RADIUS,
8
+ ERROR_INVALID_GEOMETRY_FACTOR,
9
+ ERROR_INVALID_CONCENTRATION,
10
+ ERROR_RELEASABLE_AMOUNT,
11
+ )
12
+ from dataclasses import dataclass
13
+
14
+
15
+ @dataclass
16
+ class HopfenbergParameters:
17
+ """
18
+ Parameters for the Hopfenberg model based on surface erosion.
19
+
20
+ Attributes:
21
+ k0 (float): Erosion rate constant (mg/(mm^2·s))
22
+ c0 (float): Initial drug concentration in the matrix (mg/mm^3)
23
+ a0 (float): Initial radius or half-thickness of the device (mm)
24
+ n (int): Geometry factor (1=slab, 2=cylinder, 3=sphere)
25
+ """
26
+
27
+ M: float
28
+ k0: float
29
+ c0: float
30
+ a0: float
31
+ n: int
32
+
33
+
34
+ class HopfenbergModel(DrugReleaseModel):
35
+ """Simulator for the Hopfenberg drug release model for surface-eroding polymers."""
36
+
37
+ def __init__(self, M: float, k0: float, c0: float, a0: float, n: int) -> None:
38
+ """
39
+ Initialize the Hopfenberg model with the given parameters.
40
+
41
+ :param M: entire releasable amount of drug (normally M > 0) (mg)
42
+ :param k0: Erosion rate constant (mg/(mm^2·s))
43
+ :param c0: Initial drug concentration in the matrix (mg/mm^3)
44
+ :param a0: Initial radius or half-thickness of the device (mm)
45
+ :param n: Geometry factor (1=slab, 2=cylinder, 3=sphere)
46
+ """
47
+ super().__init__()
48
+ self._parameters = HopfenbergParameters(M=M, k0=k0, c0=c0, a0=a0, n=n)
49
+ self._plot_parameters["label"] = "Hopfenberg Model"
50
+
51
+ def __repr__(self):
52
+ """Return a string representation of the Hopfenberg model."""
53
+ return (
54
+ f"drux.HopfenbergModel(M={self._parameters.M}, k0={self._parameters.k0}, "
55
+ f"c0={self._parameters.c0}, a0={self._parameters.a0}, "
56
+ f"n={self._parameters.n})"
57
+ )
58
+
59
+ def _model_function(self, t: float) -> float:
60
+ """
61
+ Calculate the fractional drug release at time t using the Hopfenberg model.
62
+
63
+ Formula:
64
+ - Mt = M∞(1 - (1 - k0*t / (c0*a0))^n)
65
+
66
+ :param t: time (s)
67
+ :return: drug release
68
+ """
69
+ M = self._parameters.M
70
+ k0 = self._parameters.k0
71
+ c0 = self._parameters.c0
72
+ a0 = self._parameters.a0
73
+ n = self._parameters.n
74
+
75
+ inner_term = 1 - (k0 * t) / (c0 * a0)
76
+
77
+ Mt = M * (1 - (inner_term**n))
78
+
79
+ return Mt
80
+
81
+ def _validate_parameters(self) -> None:
82
+ """Validate the parameters of the Hopfenberg model."""
83
+ if self._parameters.M < 0:
84
+ raise ValueError(ERROR_RELEASABLE_AMOUNT)
85
+ if self._parameters.k0 < 0:
86
+ raise ValueError(ERROR_INVALID_EROSION_CONSTANT)
87
+ if self._parameters.c0 <= 0:
88
+ raise ValueError(ERROR_INVALID_CONCENTRATION)
89
+ if self._parameters.a0 <= 0:
90
+ raise ValueError(ERROR_INVALID_INITIAL_RADIUS)
91
+ if self._parameters.n not in (1, 2, 3):
92
+ raise ValueError(ERROR_INVALID_GEOMETRY_FACTOR)
@@ -36,6 +36,11 @@ ERROR_FIRST_ORDER_INITIAL_AMOUNT = (
36
36
  # Error messages for Weibull
37
37
  ERROR_WEIBULL_SCALE_PARAMETER = "Scale parameter (a) must be positive."
38
38
  ERROR_WEIBULL_SHAPE_PARAMETER = "Shape parameter (b) must be positive."
39
- ERROR_WEIBULL_INITIAL_AMOUNT = (
39
+ ERROR_RELEASABLE_AMOUNT = (
40
40
  "Entire releasable amount of drug (M) must be non-negative."
41
41
  )
42
+
43
+ # Hopfenberg model error messages
44
+ ERROR_INVALID_EROSION_CONSTANT = "Erosion rate constant (k0) must be non-negative."
45
+ ERROR_INVALID_INITIAL_RADIUS = "Initial radius or half-thickness (a0) must be positive."
46
+ ERROR_INVALID_GEOMETRY_FACTOR = "Geometry factor (n) must be 1 (slab), 2 (cylinder), or 3 (sphere)."
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Drux parameters and constants."""
3
3
 
4
- DRUX_VERSION = "0.3"
4
+ DRUX_VERSION = "0.4"
@@ -4,7 +4,7 @@
4
4
  from .base_model import DrugReleaseModel
5
5
  from .messages import (
6
6
  ERROR_WEIBULL_SCALE_PARAMETER,
7
- ERROR_WEIBULL_INITIAL_AMOUNT,
7
+ ERROR_RELEASABLE_AMOUNT,
8
8
  ERROR_WEIBULL_SHAPE_PARAMETER,
9
9
  )
10
10
  from dataclasses import dataclass
@@ -65,7 +65,7 @@ class WeibullModel(DrugReleaseModel):
65
65
  def _validate_parameters(self) -> None:
66
66
  """Validate the parameters of the Weibull model."""
67
67
  if self._parameters.M < 0:
68
- raise ValueError(ERROR_WEIBULL_INITIAL_AMOUNT)
68
+ raise ValueError(ERROR_RELEASABLE_AMOUNT)
69
69
  if self._parameters.a <= 0:
70
70
  raise ValueError(ERROR_WEIBULL_SCALE_PARAMETER)
71
71
  if self._parameters.b <= 0:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drux
3
- Version: 0.3
3
+ Version: 0.4
4
4
  Summary: Drux: Drug Release Analysis Framework
5
5
  Home-page: https://github.com/openscilab/drux
6
- Download-URL: https://github.com/openscilab/drux/tarball/v0.3
6
+ Download-URL: https://github.com/openscilab/drux/tarball/v0.4
7
7
  Author: Drux Development Team
8
8
  Author-email: drux@openscilab.com
9
9
  License: MIT
@@ -118,9 +118,9 @@ Drux is a Python-based framework for simulating drug release profiles using math
118
118
 
119
119
  ### PyPI
120
120
  - Check [Python Packaging User Guide](https://packaging.python.org/installing/)
121
- - Run `pip install drux==0.3`
121
+ - Run `pip install drux==0.4`
122
122
  ### Source code
123
- - Download [Version 0.3](https://github.com/openscilab/drux/archive/v0.3.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
123
+ - Download [Version 0.4](https://github.com/openscilab/drux/archive/v0.4.zip) or [Latest Source](https://github.com/openscilab/drux/archive/dev.zip)
124
124
  - Run `pip install .`
125
125
 
126
126
  ## Supported Models
@@ -205,6 +205,29 @@ where:
205
205
  3. Comparative studies
206
206
  4. Vivo predictions
207
207
 
208
+ ### Hopfenberg
209
+ The Hopfenberg model describes drug release from surface-eroding polymers with a constant surface area.
210
+ It is particularly useful for modeling drug release from biodegradable polymers where the drug is uniformly distributed throughout the matrix.
211
+ According to this model, the cumulative amount of drug released at time $t$ is given by:
212
+
213
+ $$
214
+ M_t = M_{\infty} \left(1 - \left(1 - \frac{k_0t}{c_0 a_0}\right)^n\right)
215
+ $$
216
+
217
+ where:
218
+ - $M_t (mg)$ is the cumulative absolute amount of drug released at time $t
219
+ - $M_{\infty} (mg)$ is the total amount of drug released at infinite time
220
+ - $k_0 (\frac{mg}{mm^2 s})$ is the surface erosion rate constant
221
+ - $c_0 (\frac{mg}{mm^3})$ is the initial drug concentration in the polymer matrix
222
+ - $a_0 (mm)$ is the initial radius (for spheres) or half-thickness (for slabs) of the device
223
+ - $n$ is the geometry-dependent exponent (1 for slabs, 2 for cylinders, 3 for spheres)
224
+
225
+ #### Applications
226
+ 1. Biodegradable Implants
227
+ 2. Surface-eroding drug delivery systems
228
+ 3. Transdermal Patches
229
+ 4. Injectable depots
230
+
208
231
  ## Usage
209
232
  ### Zero-Order Model
210
233
  ```python
@@ -243,6 +266,17 @@ model.plot(show=True)
243
266
  ```
244
267
  <img src="https://github.com/openscilab/drux/raw/main/otherfiles/weibull_plot.png" alt="Weibull Plot">
245
268
 
269
+ ### Hopfenberg Model
270
+
271
+ ```python
272
+ from drux import HopfenbergModel
273
+ model = HopfenbergModel(M=1, k0=0.00067, c0=0.0374, a0=3.51, n=2)
274
+ model.simulate(duration=100, time_step=1)
275
+ model.plot(show=True)
276
+ ```
277
+ <img src="https://github.com/openscilab/drux/raw/main/otherfiles/hopfenberg_plot.png" alt="Hopfenberg Plot">
278
+
279
+
246
280
  ## Issues & bug reports
247
281
 
248
282
  Just fill an issue and describe it. We'll check it ASAP! or send an email to [drux@openscilab.com](mailto:drux@openscilab.com "drux@openscilab.com").
@@ -264,6 +298,9 @@ You can also join our discord server
264
298
  <blockquote>5- S. Dash, "Kinetic modeling on drug release from controlled drug delivery systems," <i>Acta Poloniae Pharmaceutica</i>, 2010.</blockquote>
265
299
  <blockquote>6- K. H. Ramteke, P. A. Dighe, A. R. Kharat, S. V. Patil, <i>Mathematical models of drug dissolution: A review</i>, <i>Sch. Acad. J. Pharm.</i>, vol. 3, no. 5, pp. 388-396, 2014.</blockquote>
266
300
  <blockquote>7- C. Corsaro, G. Neri, A. M. Mezzasalma, and E. Fazio, "Weibull modeling of controlled drug release from Ag-PMA nanosystems," <i>Polymers</i>, vol. 13, no. 17, p. 2897, 2021.</blockquote>
301
+ <blockquote>8- H. B. Hopfenberg, "Controlled release from erodible slabs, cylinders, and spheres," in <i>Controlled Release Polymeric Formulations</i>, ACS Symposium Series, vol. 33, pp. 26–32, 1976.</blockquote>
302
+ <blockquote>9- H. V. Chavda, M. S. Patel, and C. N. Patel, "Preparation and in vitro evaluation of guar gum based triple-layer matrix tablet of diclofenac sodium," <i>Research in Pharmaceutical Sciences</i>, vol. 7, no. 1, pp. 57–64, Jan. 2012.</blockquote>
303
+
267
304
 
268
305
  ## Show your support
269
306
  ### Star this repo
@@ -282,6 +319,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
282
319
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
283
320
 
284
321
  ## [Unreleased]
322
+ ## [0.4] - 2026-05-18
323
+ ### Added
324
+ - Hopfenberg model
285
325
  ## [0.3] - 2025-12-08
286
326
  ### Added
287
327
  - Weibull model
@@ -305,7 +345,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
305
345
  - Higuchi model
306
346
 
307
347
 
308
- [Unreleased]: https://github.com/openscilab/drux/compare/v0.3...dev
348
+ [Unreleased]: https://github.com/openscilab/drux/compare/v0.4...dev
349
+ [0.4]: https://github.com/openscilab/drux/compare/v0.3...v0.4
309
350
  [0.3]: https://github.com/openscilab/drux/compare/v0.2...v0.3
310
351
  [0.2]: https://github.com/openscilab/drux/compare/v0.1...v0.2
311
352
  [0.1]: https://github.com/openscilab/drux/compare/48548f0...v0.1
@@ -6,6 +6,7 @@ drux/__init__.py
6
6
  drux/base_model.py
7
7
  drux/first_order.py
8
8
  drux/higuchi.py
9
+ drux/hopfenberg.py
9
10
  drux/messages.py
10
11
  drux/params.py
11
12
  drux/weibull.py
@@ -17,5 +18,6 @@ drux.egg-info/requires.txt
17
18
  drux.egg-info/top_level.txt
18
19
  tests/test_first_order.py
19
20
  tests/test_higuchi.py
21
+ tests/test_hopfenberg.py
20
22
  tests/test_weibull.py
21
23
  tests/test_zero_order.py
@@ -33,14 +33,14 @@ setup(
33
33
  name='drux',
34
34
  packages=[
35
35
  'drux', ],
36
- version='0.3',
36
+ version='0.4',
37
37
  description='Drux: Drug Release Analysis Framework',
38
38
  long_description=read_description(),
39
39
  long_description_content_type='text/markdown',
40
40
  author='Drux Development Team',
41
41
  author_email='drux@openscilab.com',
42
42
  url='https://github.com/openscilab/drux',
43
- download_url='https://github.com/openscilab/drux/tarball/v0.3',
43
+ download_url='https://github.com/openscilab/drux/tarball/v0.4',
44
44
  keywords="drug-release drug-delivery mathematical-modeling simulation kinetics",
45
45
  project_urls={
46
46
  'Source': 'https://github.com/openscilab/drux',
@@ -0,0 +1,151 @@
1
+ """Tests for the Hopfenberg model implementation in drux package."""
2
+
3
+ from pytest import raises
4
+ from numpy import isclose
5
+ from re import escape
6
+ from drux import HopfenbergModel
7
+
8
+ TEST_CASE_NAME = "Hopfenberg model tests"
9
+ M, k0, c0, a0, n = 1, 0.00067, 0.0374, 3.51, 2
10
+ SIM_DURATION, SIM_TIME_STEP = 100, 1
11
+ RELATIVE_TOLERANCE = 1e-1
12
+
13
+
14
+ def test_hopfenberg_parameters():
15
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
16
+ assert model._parameters.M == M
17
+ assert model._parameters.k0 == k0
18
+ assert model._parameters.c0 == c0
19
+ assert model._parameters.a0 == a0
20
+ assert model._parameters.n == n
21
+
22
+
23
+ def test_invalid_parameters():
24
+ with raises(ValueError, match=escape("Entire releasable amount of drug (M) must be non-negative.")):
25
+ HopfenbergModel(M=-M, k0=k0, c0=c0, a0=a0, n=n).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
26
+
27
+ with raises(ValueError, match=escape("Erosion rate constant (k0) must be non-negative")):
28
+ HopfenbergModel(M=M, k0=-k0, c0=c0, a0=a0, n=n).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
29
+
30
+ with raises(ValueError, match=escape("Initial drug concentration (c0) must be positive.")):
31
+ HopfenbergModel(M=M, k0=k0, c0=-c0, a0=a0, n=n).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
32
+
33
+ with raises(ValueError, match=escape("Initial radius or half-thickness (a0) must be positive.")):
34
+ HopfenbergModel(M=M, k0=k0, c0=c0, a0=-a0, n=n).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
35
+
36
+ with raises(ValueError, match=escape("Geometry factor (n) must be 1 (slab), 2 (cylinder), or 3 (sphere).")):
37
+ HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=4).simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
38
+
39
+
40
+ def test_repr():
41
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
42
+ repr_str = repr(model)
43
+ assert repr_str == f"drux.HopfenbergModel(M={M}, k0={k0}, c0={c0}, a0={a0}, n={n})"
44
+
45
+
46
+ def test_hopfenberg_simulation(): # Reference: https://pmc.ncbi.nlm.nih.gov/articles/PMC3500559/
47
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
48
+ profile = model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
49
+
50
+ actual_release = [M * (1 - (1 - (k0 * t) / (c0 * a0))**n) for t in range(0, SIM_DURATION+SIM_TIME_STEP, SIM_TIME_STEP)]
51
+ assert all(isclose(p, r, rtol=RELATIVE_TOLERANCE) for p, r in zip(profile, actual_release))
52
+
53
+
54
+ def test_hopfenberg_simulation_errors():
55
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
56
+
57
+ with raises(ValueError, match="Duration and time step must be positive values"):
58
+ model.simulate(duration=-100, time_step=10)
59
+
60
+ with raises(ValueError, match="Duration and time step must be positive values"):
61
+ model.simulate(duration=100, time_step=-10)
62
+
63
+ with raises(ValueError, match="Time step cannot be greater than duration"):
64
+ model.simulate(duration=10, time_step=20)
65
+
66
+
67
+ def test_hopfenberg_plot1():
68
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
69
+ model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
70
+ fig, ax = model.plot()
71
+ assert fig is not None
72
+ assert ax is not None
73
+ assert ax.get_title() == model._plot_parameters["title"]
74
+ assert ax.get_xlabel() == model._plot_parameters["xlabel"]
75
+ assert ax.get_ylabel() == model._plot_parameters["ylabel"]
76
+ assert [text.get_text() for text in ax.get_legend().get_texts()] == [model._plot_parameters["label"]]
77
+
78
+
79
+ def test_hopfenberg_plot2():
80
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
81
+ model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
82
+ fig, ax = model.plot(title="test-title", xlabel="test-xlabel", ylabel="test-ylabel", label="test-label")
83
+ assert fig is not None
84
+ assert ax is not None
85
+ assert ax.get_title() == "test-title"
86
+ assert ax.get_xlabel() == "test-xlabel"
87
+ assert ax.get_ylabel() == "test-ylabel"
88
+ assert [text.get_text() for text in ax.get_legend().get_texts()] == ["test-label"]
89
+
90
+
91
+ def test_hopfenberg_plot_error():
92
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
93
+
94
+ with raises(ValueError, match=escape("No simulation data available. Run simulate() first.")):
95
+ model.plot()
96
+
97
+ model._time_points = [0] # manually set time points to simulate error (TODO: it will be caught with prior errors)
98
+ # manually set a too short profile to simulate error (TODO: it will be caught with prior errors)
99
+ model._release_profile = [0.0]
100
+ with raises(ValueError, match="Release profile is too short to calculate release rate."):
101
+ model.plot()
102
+
103
+
104
+ def test_hopfenberg_release_rate():
105
+ small_timestep = 0.001 # smaller time step for better accuracy in numerical derivative
106
+ small_duration = 10
107
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
108
+ model.simulate(duration=small_duration, time_step=small_timestep)
109
+ rate = model.get_release_rate().tolist()
110
+ import numpy as np
111
+ # Ref: https://www.wolframalpha.com/input?i=get+the+derivative+of+%28M+*+%281+-+%281+-+%28k0+*+t%29+%2F+%28c0+*+a0%29%29**n%29%29+with+respect+to+t
112
+ actual_rate = [
113
+ k0*M*n*((1-((k0*t)/(a0*c0)))**(n-1))/(a0*c0)
114
+ for t in np.arange(small_timestep, small_duration + small_timestep, small_timestep)
115
+ ] # avoid t=0 to prevent division by zero
116
+ assert all(isclose(r, ar, rtol=1e-1) for r, ar in zip(rate[2:], actual_rate[1:])) # skip first two points due to numerical derivative inaccuracies
117
+
118
+
119
+ def test_hopfenberg_release_rate_error():
120
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
121
+
122
+ with raises(ValueError, match=escape("No simulation data available. Run simulate() first.")):
123
+ model.get_release_rate()
124
+
125
+ model._time_points = [0] # manually set time points to simulate error (TODO: it will be caught with prior errors)
126
+ # manually set a too short profile to simulate error (TODO: it will be caught with prior errors)
127
+ model._release_profile = [0.0]
128
+ with raises(ValueError, match="Release profile is too short to calculate release rate."):
129
+ model.get_release_rate()
130
+
131
+
132
+ def test_hopfenberg_time_for_release():
133
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
134
+ model.simulate(duration=SIM_DURATION, time_step=1)
135
+ tx = model.time_for_release(0.8 * model._release_profile[-1])
136
+ # Ref: https://www.wolframalpha.com/input?i=solve+for+t+in+%281+-+%281+-+%280.00067*+t%29+%2F+%280.0374+*+3.51%29%29**2%29+%3D+0.8*0.7602750594732341
137
+ assert isclose(tx, 74, rtol=1e-2)
138
+
139
+
140
+ def test_hopfenberg_time_for_release_error():
141
+ model = HopfenbergModel(M=M, k0=k0, c0=c0, a0=a0, n=n)
142
+
143
+ with raises(ValueError, match=escape("No simulation data available. Run simulate() first.")):
144
+ model.time_for_release(0.5)
145
+ model.simulate(duration=SIM_DURATION, time_step=SIM_TIME_STEP)
146
+
147
+ with raises(ValueError, match="Target release must be non-negative."):
148
+ model.time_for_release(-0.1)
149
+
150
+ with raises(ValueError, match="Target release exceeds maximum release of the simulated duration."):
151
+ model.time_for_release(model._release_profile[-1] + 0.1)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes