-
Notifications
You must be signed in to change notification settings - Fork 1
๐ฐ Multiple Inheritance for food contact conditions
SFPPy leverages multiple inheritance to define custom food contact scenarios with minimal effort. This approach allows users to seamlessly combine different properties (e.g., temperature, texture, and chemical affinity) into a single class, making simulation setup both intuitive and flexible.
This page explains how multiple inheritance enables:
- Customization ๐จ: Easily define new contact conditions
- Reusability ๐: Combine existing behaviors instead of rewriting code
- Extensibility ๐: Adapt models to real-world packaging scenarios
In SFPPy, food contact conditions are defined as classes that inherit from multiple base classes. Each base class represents a specific aspect of the food contact condition, such as:
-
Storage conditions (e.g.,
ambient
,hotfilled
,chilled
) -
Food texture, medium polarityโฆ (e.g.,
fat
,liquid
) -
Food processing conditions (e.g.,
boiling
,frying
) -
Setoff conditions (e.g.,
stacked
)
By combining these classes, a new contact scenario can inherit properties from all relevant categories without needing additional code.
We can create a new composite contact condition by inheriting from existing classes:
from patankar.food import stacked, hotfilled, liquid, fat, ambient
class contact1(stacked, ambient):
name = "1:setoff"
contacttemperature = (20, "degC")
contacttime = (3, "months")
class contact2(hotfilled, liquid, fat):
name = "2:hotfilling"
class contact3(ambient, liquid, fat):
name = "3:storage"
contacttime = (6, "months")
Each class inherits attributes from its base classes:
โ
stacked
โ Defines a setoff condition (periodic boundary conditions) ๐ฆ
โ
ambient
โ Assigns storage at 20ยฐC ๐ก๏ธ
โ
hotfilled
โ Models hot-filling at 90ยฐC ๐ฅ
โ
liquid
, fat
โ Define food texture ๐ฅ
from patankar.food import fat, ambient, hotfilled, stacked
from patankar.loadpubchem import loadpubchem
from patankar.layer import gPET, PP
# Define the migrant
m = loadpubchem('limonene')
# Define packaging structure
A = gPET(l=(20, "um"))
B = PP(l=(500, "um"), migrant=m, CP0=200)
ABA = A + B + A
# Instantiate food contact conditions
medium1 = contact1(contacttime=(4, "months"))
medium2 = contact2()
medium3 = contact3()
# Simulate migration
medium1 >> ABA >> medium1 >> medium2 >> medium3
# Combine results
sol123 = medium1.lastsimulation + medium2.lastsimulation + medium3.lastsimulation
sol123.plotCF()
๐น Each food contact step maintains unique properties ๐ ๐น Minimal code needed to define new scenarios ๐ฏ ๐น Works seamlessly with existing SFPPy simulations โก
- No need to manually define attributes like temperature and time ๐
- Just combine existing behaviors via class inheritance ๐จ
- Modify only the needed properties while reusing the rest โ
- Enables fine-grained control over each scenario ๐ฏ
- No redundant codeโreuse base classes instead ๐๏ธ
- Multiple simulation scenarios can share the same logic ๐
SFPPyโs use of multiple inheritance makes it easy to define custom contact conditions with minimal code. By simply inheriting from predefined classes, users can construct realistic and complex food contact scenarios efficiently. ๐
๐ SFPPy - Python Framework for Food Contact Compliance & Risk Assessment ๐โฉ๐
- ๐ฅ Download SFPPy
- ๐ SFPPy Documentation
- ๐งฎ Migration Modeling Guide
- ๐งโ๐ FitNESS E-learning Platform - (Details)