Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
This package is a Julia complement to [LyoPRONTO](https://github.com/LyoHUB/LyoPronto), an open source Python package.
It has some overlapping functionality with LyoPRONTO, especially simulation of primary drying for conventional lyophilization.
LyoPRONTO (the Python version) also has functionality for generating a design space, estimating time to freeze, and picking optimal drying conditions.
On the other hand, this package has much more advanced utilities for fitting empirical parameters (such as $R_p$ and $K_v$) to experimental data.
On the other hand, this package has much more advanced utilities for fitting empirical parameters (such as $R_p$ and $K_v$) to experimental data.
This package also provides that fitting functionality for a model applicable to microwave-assisted lyophilization.

## Installation

From the Julia REPL's Pkg mode (open a REPL and type `]` so that the prompt turns blue), add this package as a Git repo:
From the Julia REPL's Pkg mode (open a REPL and type `]` so that the prompt turns blue), add this package from the General registry with:
```
add https://github.com/LyoHUB/LyoPronto.jl.git
add LyoPronto
```


## Documentation

The "badge" up above is a link to the documentation.
The "badge" up above is a link to the documentation, which is [also here](https://lyohub.github.io/LyoPronto.jl/).

## Versioning

Expand All @@ -28,7 +30,7 @@ This work was supported in part by funding for NIIMBL project PC4.1-307 .

## License

None yet. My intentions are to use the MIT license once this has been published in a scientific journal.
MIT License; see `LICENSE` file.

# Example usage

Expand Down
3 changes: 1 addition & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
LyoPronto = "86014da0-a5b3-40a4-ad76-3e66dfc3e269"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
SavitzkyGolay = "c4bf5708-b6a6-4fbe-bcd0-6850ed671584"
Expand All @@ -20,6 +18,7 @@ TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
[compat]
Plots = "1.41"
NonlinearSolve = "4.9"
OptimizationOptimJL = "0.4.6"

[sources]
LyoPronto = {path = ".."}
3 changes: 2 additions & 1 deletion docs/example/fitting_mannitol.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ using TypedTables, CSV
# TransformVariables provides tools for mapping optimization parameters to sensible ranges.
using TransformVariables
# Optimization provides a common interface to a variety of optimization packages, including Optim.
# We import it with OptimizationOptimJL to specify Optim as a backend.
# LineSearches gives a little more granular control over solver algorithms for Optim.
using Optimization, OptimizationOptimJL
using OptimizationOptimJL
using LineSearches
# Or, instead of using a scalar optimization package, we can use a least-squares solver.
using NonlinearSolve
Expand Down
3 changes: 3 additions & 0 deletions src/LyoPronto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import OrdinaryDiffEqRosenbrock: ODEProblem
@reexport using Unitful: @u_str, ustrip, uconvert, NoUnits
import Unitful
using TransformVariables
using TransformVariables: logit
using RecipesBase
using ColorTypes: RGB
using CSV
Expand All @@ -23,6 +24,7 @@ using ADTypes: AutoForwardDiff
using DocStringExtensions
using LinearAlgebra: Diagonal


abstract type ParamObj end

const odealg_chunk1 = Rodas4(autodiff=AutoForwardDiff(chunksize=1))
Expand Down Expand Up @@ -54,6 +56,7 @@ export ParamObjRF
# parameter fitting tools
export gen_sol_pd, obj_pd, gen_nsol_pd, objn_pd
export KRp_transform_basic, K_transform_basic, Rp_transform_basic, KBB_transform_basic
export KBB_transform_bounded
export obj_expT, err_expT, err_expT!, num_errs, nls_pd, nls_pd!
export ConstWrapTV
# plotting tools (mostly already done by macros)
Expand Down
15 changes: 15 additions & 0 deletions src/paramfits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ function KBB_transform_basic(Kvwfg, Bfg, Bvwg)
return tr
end

"""
$(SIGNATURES)
Construct a bounded transform for fitting Kvwf, Bf, and Bvw (as for a microwave cycle).

`Kvwf_scalefac`, `Bf_scalefac`, and `Bvw_scalefac` are used to provide upper and lower
bounds on the fitted parameter, as `(Kvwfg/Kvwf_scalefac, Kvwfg*Kvwf_scalefac)`, etc.
This is enforced with a logistic transform scaled and shifted appropriately.
"""
function KBB_transform_bounded(Kvwfg, Bfg, Bvwg; Kvwf_scalefac=1e2, Bf_scalefac=1e4, Bvw_scalefac=1e4)
tr = as((Kvwf = TVScale(Kvwfg*Kvwf_scalefac) ∘ TVLogistic() ∘ TVShift(logit(inv(Kvwf_scalefac))),
Bf = TVScale(Bfg*Bf_scalefac) ∘ TVLogistic() ∘ TVShift(logit(inv(Bf_scalefac))),
Bvw = TVScale(Bvwg*Bvw_scalefac) ∘ TVLogistic() ∘ TVShift(logit(inv(Bvw_scalefac))) ))
return tr
end

"""
$(SIGNATURES)

Expand Down
6 changes: 1 addition & 5 deletions test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
LyoPronto = "86014da0-a5b3-40a4-ad76-3e66dfc3e269"
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Optimization = "7f7a1694-90dd-40f0-9382-eb1efda571ba"
OptimizationOptimJL = "36348300-93cb-4f02-beb5-3c3902f8871e"
SavitzkyGolay = "c4bf5708-b6a6-4fbe-bcd0-6850ed671584"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand All @@ -20,8 +18,6 @@ LyoPronto = {path = ".."}
Aqua = "0.8"
LineSearches = "7.3"
NonlinearSolve = "4.9"
Optim = "1.9"
Optimization = "4.3"
OptimizationOptimJL = "0.4"
OptimizationOptimJL = "0.4.6"
Test = "1"
TypedTables = "1"
2 changes: 1 addition & 1 deletion test/test_KRp_opt.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TransformVariables
using Optimization, OptimizationOptimJL
using OptimizationOptimJL
using LineSearches
using NonlinearSolve
optalg = LBFGS(linesearch=LineSearches.BackTracking())
Expand Down
2 changes: 1 addition & 1 deletion test/test_RF_opt.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TransformVariables
using Optimization, OptimizationOptimJL
using OptimizationOptimJL
using LineSearches
optalg = LBFGS(linesearch=LineSearches.BackTracking())

Expand Down
Loading