Git Product home page Git Product logo

snow's Introduction

tag pypi build Coverage Status

SNOW (Stochastic Nucleation Of Water) is an open source modeling framework to simulate the freezing process in a large number of vials, tailored towards pharmaceutical freeze-drying processes. SNOW was developed as part of a research collaboration between ETH Zurich's Separation Processes Laboratory and Janssen (pharmaceutical companies of J&J). It is brought to you by Leif-Thore Deck, Andraž Košir and Dr. David Ochsenbein.

Description

SNOW is a model capable of simulating the entire freezing process for a batch of vials, from the liquid state to the completely frozen state. It combines balance equations, thermodynamics and a stochastic approach to ice nucleation to provide a comprehensive view of freezing and is entirely derived from first principles.

In addition to the simulation of the thermal evolution of vials during freezing, SNOW tracks a number of characteristic quantities of the freezing process for each vial. These quantities are the nucleation time, the nucleation temperature and the solidification time. Both nucleation and solidification are correlated with attributes of the frozen product such as the mean crystal size and the product activity of an API. Variability in these quantities among vials may thus be used as surrogate for batch heterogeneity. SNOW consequently may be used in process design and optimization to identify suitable cooling protocols with sufficiently small batch heterogeneity.

A more detailed description of the modeling framework is presented in a recent publication, which is publicly accessible under https://doi.org/10.1016/j.ijpharm.2021.121276 While version 1.0 is tailored towards simulations of the freezing stage in freeze-drying, version 1.1. was developed for pallet freezing; pallet freezing is for example used in the manufacturing of the Janssen COVID-19 vaccine, which served as case study for the model. Version 1.1 and the case study on the COVID-vaccine are discussed in detail in a recent scientific publication: https://doi.org/10.1016/j.ijpharm.2022.122051

An extension of the modeling framework for the simulation of the freezing process with spatial resolution within individual containers has been implemented in version 2.0 and is discussed in detail within the scope of a recent scientific publication: https://doi.org/10.1016/j.cej.2024.148660.

Additional features supported by version 2.0

  • Spatial simulation of freezing within individual containers with different dimensionalities (0D, 1D, 2D)
  • Simulation of three process configurations (shelf-ramped freezing, vacuum-induced surface freezing, jacket-ramped freezing)

Additional features supported by version 1.1

  • Simulation of systems comprising vials arranged in three spatial dimensions
  • Arbitrary initial temperature of the vials
  • Improvements in the numerical implementation (Second method to compare the initial amount of ice formed, faster data saving)

Features supported as of version 1.0

  • Simulation of the thermal evolution and ice formation for a batch with arbitrary number of vials
  • Arbitrary cooling protocols (i.e., user may choose cooling rate, integrate holding steps and controlled nucleation)
  • Tracking of nucleation times, temperatures and solidification times for all vials
  • Stochastic nucleation in the form of a Monte Carlo approach as well as controlled nucleation in the form of forced initiation of nucleation at a certain point in time
  • Cubic geometry of vial and rectangular arrangement on the shelf

Features in preparation

  • Hexagonal arrangement of vials on the shelf for freeze-drying
  • Additional modes of heat transfer (e.g. thermal radiation)
  • Alternative vial / vessel geometries

Bug reports

Please report bugs as Github issues or via Email, preferably including a screenshot that illustrates the problem.

Copyright (c) 2021-2024 Leif-Thore Deck, Andraž Košir, David Ochsenbein

The snow package logo has been designed using resources from Flaticon.com.

snow's People

Contributors

akosira avatar bizzinho avatar ltdeck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

victornemenike

snow's Issues

Vectorization

Hey Leif, can you add more comments re what's happening in the 'vectorization' part and right after? Maybe with better documentation I get it just by reading.

parfor loop

(This is a test to see how to open an issue.)

Hey Dave,

let me explain the general concepts about the part following the vectorization, i.e. the parfor loop. Basically this part is the "heart" of the model.

The loop runs the individual simulations of the freezing process in parallel, which is very handy since the runtime scales well with the number of available cores. To allow for reproducibility, it is necessary to initialize the random number generator in each iteration and to this differently.

The loop starts with a couple of definitions; they are temporary variables required to pass values to the outside of the loop. This also includes the state variables (T_time and sigma_time), for which I also extract some values, which is needed to make the thermal evolution figures.

There are two nested loops within the parfor loop. The outer one is the time loop, the inner one goes through all vials. For each timestep I calculate the heat flows q and store some information on the vials states.

The inner loop is based on an if..else structure, comprising the two cases liquid and ice growth state, which we distinguish based on the value of sigma. In the ice growth state, we calculate the new state variables by following the freezing point depression curve in the phase diagram. Doing so is a bit ugly, so I think I will make a slide outlining the equations here. When a certain ice fraction is reached (i.e. 90% here), we define that the solidification time is reached. However, the vial stays in this state also afterwards.

The second state is the liquid one. Here we just follow the energy balance and calculate the new temperature in each step. If supercooled, we test for stochastic nucleation. There is also the possibility to do controlled nucleation (i.e. when setting cont = 1), where nucleation will be forced at iteration i == T_insert_end. When nucleation is induced, we calculate the initial sigma and T in the same way as in the ice growth state.

Thats's basically it. We also need to define some more variables to extract the data from the loop. Also, after the loop I restructure the output variables in a 4D tensor (i.e. based on the number of vials in x,y, and z direction), because I used this format before vectorizing and I still use it for figures.

Please let me know if anything is unclear.

Controlled nucleation of non-supercooled vials

Hey @ltdeck, asking myself what the right behavior is for vials that are not supercooled at the end of holding, when controlled nucleation would be triggered.

Right now, only vials that are both liquid and supercooled are nucleated by controlled nucleation at the end of holding. What is the right behavior for vials that are not supercooled yet?

  1. They should nucleate spontaneously whenever the dice decide
  2. They should nucleate as soon as they become supercooled
  3. They should nucleate as soon as they become supercooled if that time is within X seconds of the nucleation trigger, otherwise they should nucleate spontaneously whenever the dice decide.

Shelf temperature profile in plot function

The current plot() function does not show the thermal evolution of the shelf. When selecting temperature trajectories, only those for the vials are shown. For validation, it would be helpful to also directly see the shelf temperature.

Axis labeling in plot function

The plot() function currently does not autogenerate physically meaningful labels for the x- and y-axis. This may impact the user experience. For the example below, that shows a box plot of simulated nucleation temperatures, I would recommend the following:
x-label: "vial position"
y-label: "nucleation temperature [°C]"

Ideally, the function would autogenerate such labels depending on the type of plot.

labeling

Multiple holding steps

Can only have one right now, need to allow for multiple (pre and post controlled nucleation, e.g.)

Saving process for generated data is slow

When saving the pallet files for the 3D model validation, I noticed an excessive runtime for the first set up of data saved, see figure below:

slowdatasaving

The issue refers to the current version of the snowfall_validation file. However, I also noticed similar issues before; due to the smaller scale of the box and 2-D shelf simulations, this likely went unnoticed for quite some time.

Progress update information for snowfall

Given that snowfall simulations may take some time to complete the simulation, it would be helpful to know the current progress of the simulation. For example, one may add the functionality that snowfall provides the number of completely simulated repetitions in live.

Controlled nucleation does not work in case vials are not supercooled

When using controlled nucleation, it may be possible that some vials are not supercooled at the time of the nucleation event. The program accounts for this by not introducing nucleation. However, there is no warning provided for the user to understand this situation. I think this may be helpful, however.

Look at the following example: In theory, nucleation should occur at the end of the first holding step at -5°C, however at this time the vial temperature is above 0°C, thus nothing happens. As we would expect in reality, nucleation occurs stochastically after the second holding step. However, there is no warning for the user that such behavior was observed. Indeed, it is only possible to understand it via plotting the thermal trajectories.

nocontrol

Direct readout of characteristic quantities from snowfall

Snowfall currently does not allow for an explicit argument to store states like snowflake. Consequently, the characteristic quantities (nucTemp etc) are automatically stored in stats_df, but not accessible via the direct functions, i.e. nucleationTemperatures(). This may be an issue since snowfall and snowflake behave different. For snowflake, direct access to the quantities is possible as of now.

Code:

from ethz_snow.snowfall import Snowfall
S = Snowfall(Nrep=10,N_vials=(3,3,1))
S.run()
S.plot(what="T_nucleation")
S.stats_df
S.nucleationTemperatures()

Screenshots:
nostates
statsdf

Variability in shelf-to-vial HT coefficient

from ethz_snow.snowflake import Snowflake
d = {"int": 20, "ext": 20, "s0": 20, "s_sigma_rel": 0}
S = Snowflake(storeStates='all',N_vials=(7,7,1),k=d)
S.run()
S.k

When manually adjusting the heat transfer parameters, the effect on the 'shelf' parameters in k is unclear. Setting s_sigma_rel to 0 or to a value higher than 0.1 has no significant impact. Also, when increasing s0 to 2000, the absolute difference between s0 and the 'shelf' parameters remains the same, while it should increase since it is defined in relation to s0.

bug1
bug1a

Mismatch Matlab vs Python

In the Matlab code, the kshelf heterogeneity is calculated with a different random seed for every simulation. The python code currently does not do this. Need to update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.