SFPPy - Python Framework for Food Contact Compliance and Risk Assessment ๐Ÿโฉ๐ŸŽ


 

๐Ÿโฉ๐ŸŽ SFPPy for Food Contact Compliance and Risk Assessment
Contact Olivier Vitrac for questions | Website | Documentation

 

Table of Contents

๐Ÿ› ๏ธ Overview

SFPPy is a Python-based framework for compliance testing of food contact materials and recycled plastic safety assessment under:

 

This project translates well-established chemical migration models from MATLAB/Octave and other languages to pure Python๐Ÿ, ensuring minimal dependencies.

๐Ÿ’ก If you need background or training, please refer to ๐Ÿ“• this book on migration modeling or the European training platform ๐Ÿ‘จ๐Ÿผโ€๐Ÿ’ป FitNESS.

โœจNote that can also fit your own experimental ๐Ÿงซโฒ๐ŸŒกmigration kineticswith SFPPy (see example 4) and explore new strategies to identify โš—๏ธ partition coefficients and ๐ŸŽฒ diffusivities from โš›molecular structures.

 

๐Ÿ“ Main Modules (Located in patankar/)

moduledescription
migration.py ๐Ÿ—๏ธCore solver using a Patankar finite-volume method for mass transfer modeling.
geometry.py ๐Ÿ“Defines 3D packaging geometries and calculates volume/surface area.
food.py ๐ŸŽModels food layers and their interactions with packaging.
layer.py ๐Ÿ“œDefines materials and layers for multilayer packaging.
property.py ๐Ÿ“ŠComputes physical and chemical properties (e.g., diffusion, partitioning).
loadpubchem.py ๐Ÿ”ฌRetrieves molecular properties from PubChem and ToxTree (cached locally).

Why Patankar?

โ“˜ The patankar folder is named in honor of ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ผSuhas V. Patankar, who developed and popularized the ๐Ÿ”ข finite volume method, which this project adapts for mass transfer problems with an arbitrary number of เชœโ€โžด Rankine discontinuities.

๐Ÿ”ง The modules include a ๐Ÿง knowledge management system via extensible ๐ŸPython classes, allowing easy expansion to cover additional cases and implement new ๐Ÿ”ฎprediction methods and models. I recommend this reading if you plan to โŒจ modify SFFPy for your own needs.

 


๐Ÿš€ | 1 | QUICK START

๐Ÿ”ง SFPPyย is built on a minimum number of packages ๐Ÿ“ฆ๐Ÿ“ฆ, which are all standard. Customized libraries are included in ๐Ÿ“patankar/private/ย and do not require specific installation.ย 

 


 

๐Ÿ’ก | 2 | USAGE SNIPPETS

โ“˜ SFPPy is fully object-oriented and supports multiple syntax styles, ranging from a functional approach to a more abstract, operator-driven paradigmโ€”all in a ๐Ÿ Pythonic manner. The snippets below demonstrate both approaches.

 

| 2.1 | Snippet 1๏ธโƒฃ | Simple Migration Simulation

๐Ÿ“ Notations: D is the diffusivity, l is the thickness layer, and C0 is the initial concentration.

CFCx

 


 

| 2.2 | Snippet 2๏ธโƒฃ | Retrieving Molecular Properties and Toxicological Data

๐Ÿ’ก The examples show how to inject m intoย  F=food (various classes )ย and P=polymer layer (various classes) to get customized and conservative simulations for specific substances and polymers. All properties, diffusivities D, Henry-like coefficients kย are calculated automatically based from their names.

 

Add toxicological data from Toxtree

output

๐Ÿ’ก A local installation of Toxtree (java) is included with SFPPy

 

For the European FCM and Articles Regulation, Annex I - Authorised Substances, use the ECHA webpage

 


 

| 2.3 | Snippet 3๏ธโƒฃ | Defining a Custom Packaging Shape

๐Ÿ’ก The examples show how to use either pkg or its properties to achieve mass transfer simulation for a specific geometry.

โš ๏ธ Note: To efficiently simulate the migration of substances from packaging materials, SFPPy unfolds complex 3D packaging geometries into an equivalent 1D representation. This transformation assumes that substance desorption is predominantly governed by diffusion within the walls of the packaging.

๐Ÿ” The geometry.py module provides tools to compute surface-area-to-volume ratios, extract wall thicknesses, and generate equivalent 1D models for mass transfer simulations.

 


 

| 2.4 | Snippet 4๏ธโƒฃ | Using โฉ as Mass Transfer Operator in Chained Simulations

๐Ÿ“Œ SFPPy leverages multiple inheritance to define food contact conditions by combining storage conditions, food types, and physical properties.

๐Ÿ“Œ Additionally, two operators play a key role in SFPPyโ€™s intuitive syntax:

With these operators, mass transfer can be abstracted into a simple, visual representation:

  1. ๐Ÿโฉ๐ŸŽ
    (Direct transfer from green to red, symbolizing migration.)

  2. ๐Ÿโฉ๐ŸŸ โฉ๐ŸŽ
    (Includes an intermediate step, depicting progressive migration.)

  3. ๐Ÿโฉ๐ŸŸกโฉ๐ŸŸ โฉ๐ŸŽ
    (More detailed, illustrating multiple contamination stages over time.)

  4. ๐Ÿโšกโฉ๐ŸŽ
    (Emphasizes active food transformation, with accelerated mass transfer.)

๐ŸŒŸ SFPPy makes this abstraction possible with simple, expressive code.

CF

๐Ÿงฉ How It Works

Each contact class inherits attributes from multiple base classes, allowing flexible combinations of:

  1. ๐Ÿ“Œ Storage Conditions:

    • ambient: Defines standard storage at room temperature

    • hotfilled: Represents high-temperature filling processes

    • stacked: Models setoff migration when packaging layers are stacked

  2. ๐Ÿฅ˜ Food Types & Interactions:

    • realfood: Represents actual food matrices

    • liquid: Specifies that the food is a liquid

    • fat: Indicates a fatty food, influencing partitioning behavior

๐Ÿ”ฌ By combining these components, SFPPy allows streamlined, physics-based simulations with minimal code. ๐Ÿš€

 


 

๐Ÿ’ก Dynamic parameter binding using layerLink connections allows: โœ… Dynamic updates of D, k, l, C0 abd T for specific layers only ( index [i] refers to the layer i+1). โœ… Seamless integration of simulation and optimization tasks. โœ… Robust handling of parameter uncertainties in complex simulation scenarios.

 


 

๐Ÿ“– | 3 | CASE STUDIES

The project includes four detailed examples (example1.py, example2.py, example3.py, and **example4.py**), showcasing real-world scenarios with various materials, substances, food types, geometries, and usage conditions.

 

| 3.1 | Example 1: | Mass Transfer from โ™ถ Monolayer Materials


| 3.2 | Example 2 | Mass Transfer in โ™ป๏ธ Recycled PP Bottles


| 3.3 | Example 3 | Advanced Migration Simulation โ›“๏ธ with Variants


| 3.4 | Example 4 | Parameter Fitting and Optimization โš™๏ธ

 


 

โš ๏ธ Disclaimer: These examples do not discuss sources of uncertainty. Please refer to our publications for details on the limitations of the presented approaches and assumptions.

 


 

๐ŸŒŸ | 3 | Why SFPPy?

โœ” SFPPy: is free and opensource. โœ” SFPPy: accepts any unit as (value,"unit") or ([value1,value2...],"unit"). โœ” Operator-based chaining: >> handles automatic mass transfer and property propagation โœ” Minimal code for complex simulations: + joins layers and merges results across storage conditions โœ” Pythonic abstraction: Works with PubChem, ToxTree, predefined polymer materials, and 3D packaging geometries โœ” Built-in visualization & export: Supports Excel (.xlsx), CSV, PDF, PNG and Matlab (if its really needed)

๐Ÿ”ฌ SFPPy powers scalable, real-world safe food packaging simulations.

 


For further details, consult the online documentation and the release page for new capabilities.


 

๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ
๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐ŸŽ๐ŸŽ๐ŸŽ๐Ÿฝ๏ธ๐ŸŽ๐ŸŽ๐ŸŽ๐ŸŽ๐ŸŽ๐Ÿฝ๏ธ๐Ÿ๐Ÿ๐Ÿ๐Ÿ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐ŸŽ๐ŸŽ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ
๐Ÿฝ๏ธ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ
๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐ŸŽ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐ŸŽ๐ŸŽ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿ๐Ÿ๐Ÿ๐Ÿ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐ŸŽ๐ŸŽ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ๐Ÿฝ๏ธ
๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐Ÿฝ๏ธ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ
๐Ÿฝ๏ธ๐ŸŽ๐ŸŽ๐ŸŽ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐ŸŽ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ
๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ๐Ÿฝ๏ธ v1.30

Enlarge your window if you cannot read the logo. The snake is the totem for Python