Skip to content

gstinoco/mGFD_Skin_Diffusion_Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Skin Diffusion Simulator with GFD 🧬

Skin Diffusion Simulator with GFD logo

GitHub Python NumPy SciPy Matplotlib Numba License: MIT

High-Performance Computational Framework for Skin Diffusion Modeling

Advanced numerical simulation using Generalized Finite Differences for biomedical applications

🔗 Quick Links

🚀 Quick Start 📦 Install 🧮 Model 🎬 Visualizations 👥 Team 🤝 Contribute 🏭 Partners 🙏 Thanks


📋 Table of Contents


🌟 Overview

This repository presents a state-of-the-art computational framework for modeling substance diffusion in biological tissues using the Generalized Finite Differences (GFD) method. The simulator provides high-performance solutions for studying drug delivery, cosmetic penetration, and biomedical transport phenomena in skin layers.

🔧 Key Capabilities

  • 🧬 Biological Modeling: 2D transient diffusion equation solver for skin tissue simulation
  • ⚡ High-Performance Computing: Numba JIT compilation for maximum computational efficiency
  • 🎯 Scientific Accuracy: GFD method implementation for irregular mesh handling
  • 🔄 Automated Dataset Generation: Parallel processing for large-scale parameter studies
  • 📊 Advanced Visualization: Comprehensive plotting and analysis tools

🔬 Applications

Field Application Use Case
Pharmacology 💊 Drug Delivery Transdermal absorption studies, dosage optimization
Cosmetics 💄 Skin Penetration Formulation analysis, safety assessment
Dermatology 🏥 Clinical Research Pathological transport, treatment efficacy
Biomedical Engineering ⚙️ Device Design Patch development, delivery system optimization
Machine Learning 🤖 AI Training Dataset generation, pattern recognition

✨ Features

🧮 Numerical Modeling

  • 2D Transient Diffusion Solver: GFD implementation with 9-point stencil
  • Flexible Boundary Conditions: Mixed Dirichlet-Neumann conditions for realistic modeling
  • Adaptive Time Stepping: CFL condition enforcement for numerical stability
  • Irregular Mesh Support: GFD method handles complex geometries

⚡ High-Performance Computing

  • Numba JIT Compilation: Just-in-time optimization for critical functions
  • Vectorized Operations: NumPy-based efficient array computations
  • Memory Optimization: Efficient data structures for large-scale simulations
  • Parallel Processing: Multi-core support for dataset generation

📊 Data Generation & Analysis

  • Large-Scale Dataset Creation: Configurable parameter sweeps (e.g., 90,000 simulations per region mesh for a 100×900 sweep)
  • Parameter Space Exploration: Systematic variation of diffusion coefficients and initial conditions
  • Automated Data Management: Hierarchical organization and compression
  • Scientific Visualization: Advanced plotting with Matplotlib

🎯 Biomedical Applications

  • Skin Layer Modeling: Realistic tissue geometry representation
  • Substance Transport: Drug, cosmetic, and chemical diffusion simulation
  • Clinical Validation: Framework for experimental data comparison
  • Predictive Modeling: Machine learning dataset preparation

📦 Installation & Setup

💻 System Requirements

Component Minimum Recommended
Python 3.8+ 3.9+
RAM 8 GB 16 GB+
CPU 4 cores 8+ cores
Storage 5 GB 25 GB+ (for datasets)
OS Windows/Linux/macOS Linux (optimal performance)

📋 Dependencies

# Core scientific computing
numpy >= 1.20.0           # Numerical computations
scipy >= 1.7.0            # Scientific algorithms
matplotlib >= 3.4.0       # Scientific plotting
numba >= 0.54.0           # JIT compilation
tqdm >= 4.62.0            # Progress bars

Quick Installation

# Method 1: Direct installation
git clone https://github.com/gstinoco/mGFD_Skin_Diffusion_Simulator.git
cd mGFD_Skin_Diffusion_Simulator
pip install -r requirements.txt

# Method 2: Virtual environment (recommended)
python -m venv skin_diffusion_env
source skin_diffusion_env/bin/activate  # On Windows: skin_diffusion_env\Scripts\activate
pip install -r requirements.txt

# Method 3: Conda environment
conda create -n skin_gfd python=3.9
conda activate skin_gfd
pip install -r requirements.txt

✅ Installation Verification

# Test installation
python -c "import numpy, scipy, matplotlib, numba, tqdm; print(':white_check_mark: Installation successful!')"

# Run quick demo
python GFD_skin.py

🚀 Quick Start

⚡ Single Simulation (Recommended)

# Run basic skin diffusion simulation
python GFD_skin.py

🚧 Dataset Generation

# Generate complete training datasets
python create_dataset.py

🔧 Advanced Usage Examples

# Select a region mesh (.mat) from region/ (e.g., skin061, skin224, skin256)
# For single simulations, change the region file inside GFD_skin.py main()

# Parameter exploration
# Modify diffusion coefficient (nu) and initial concentration (ci) in main()

# Memory optimization for large datasets
# Adjust batch sizes in create_dataset.py

🧬 Available Mesh Configurations

# Standard resolution meshes
region/skin061.mat        # 61×61 nodes, ~3.7K points
region/skin224.mat        # 224×224 nodes, ~50K points
region/skin256.mat        # 256×256 nodes, ~65K points
region/skin*.mat          # More mesh resolutions available

# Original skin layer
region/skin_base.png      # Base for the geometries

📖 Usage Guide

Practical workflows for running simulations and generating datasets

⚡ Single Simulation

Step What to do
1) Run
python GFD_skin.py
2) Outputs Images: skin.png, skin2.png (saved in the project root)
3) Customize Edit main() in GFD_skin.py to set the region mesh, diffusion coefficient (nu) and inlet concentration (c_i).

🚧 Dataset Generation (Interactive)

Step What to do
1) Run
python create_dataset.py
2) Select mesh Choose a region from region/ (e.g., skin061, skin224, skin256).
3) Configure sweep The script requests a range for nu as integer multipliers of 1e-8, plus c_i range, time steps, workers, and optional compression.
4) Outputs Images: Dataset/<region>/ci_###/nu_XXXXXXXX.png
Optional: Dataset/<region>/ci_###.zip

🎥 Visualizations

🖼️ Sample Visualizations Gallery

🔬 Comparative Diffusion Analysis

Concentration Initial = 100 | Different Diffusion Coefficients

Low Diffusion
$\nu = 1 \times 10^{-8}$

Low Diffusion
Medium Diffusion
$\nu = 4.5 \times 10^{-6}$

Medium Diffusion
High Diffusion
$\nu = 9 \times 10^{-6}$

High Diffusion

📊 Dataset Scale: A full sweep is 100 initial conditions × 900 diffusion coefficients (= 90,000 simulations per region mesh)


📂 Project Architecture

Core Components

:package: GFD-Skin-ML/
├── GFD_skin.py                             # Main simulator module
│   ├── difusion_skin_jit()                 # JIT-optimized solver
│   ├── difusion_skin()                     # Vectorized solver
│   ├── Gammas()                            # GFD coefficient calculator
│   └── main()                              # Workflow orchestrator
│
├── create_dataset.py                       # Automated dataset generation
│   ├── Parallel processing support         # Multi-core optimization
│   ├── Parameter space exploration         # Systematic variation
│   ├── Automated data management           # File organization
│   └── Memory optimization                 # Efficient resource usage
│
├── requirements.txt                        # Python dependencies
├── LICENSE                                 # MIT License
│
├── region/                                 # Computational mesh library
│   ├── skin224.mat                         # Standard resolution mesh ($224 \times 224$)
│   ├── skin256.mat                         # High resolution mesh ($256 \times 256$)
│   ├── skin_base.png                       # Geometry visualization
│   └── red files/                          # Mesh generation files
│
├── Dataset/                                # Generated simulation datasets
│   └── <region>/                           # e.g., skin061, skin224, skin256
│       ├── ci_001/                         # Initial concentration folder
│       │   ├── nu_0.00000001.png           # One simulation (nu formatted with 8 decimals)
│       │   └── ...                         # More diffusion coefficients
│       ├── ci_002/
│       ├── ...
│       └── ci_001.zip                      # Optional compressed archive (one per ci_###)
│
└── docs/                                   # Documentation and examples
    └── visualizations/                     # Sample visualization gallery
        ├── comparison_nu_1e8_ci100.png     # Low diffusion coefficient example
        ├── comparison_nu_450e8_ci100.png   # Medium diffusion coefficient example
        └── comparison_nu_900e8_ci100.png   # High diffusion coefficient example

📚 Mathematical Model

The simulator solves the 2D transient diffusion equation:

$$\frac{\partial u}{\partial t} = \nu \nabla^2 u$$

Where:

  • $u(x,y,t)$: Concentration field [mg/L]
  • $\nu$: Diffusion coefficient [m²/s]
  • $\nabla^2$: Laplacian operator
  • $t$: Time [s]

🧮 Numerical Methods

Component Method Description
Spatial Discretization Generalized Finite Differences (GFD) 9-point stencil for irregular meshes
Temporal Integration Explicit Euler First-order time stepping
Boundary Conditions Mixed Dirichlet-Neumann Inlet concentration + zero-flux boundaries
Stability CFL Condition Automatic time step adjustment

🎯 Boundary Conditions

  • Inlet (Dirichlet): $u = c_i$ (prescribed concentration)
  • Boundaries (Neumann): $\frac{\partial u}{\partial n} = 0$ (zero flux)
  • Initial Condition: $u(x,y,0) = 0$ (clean tissue)

🗄️ Dataset Structure

The generated datasets follow a hierarchical organization:

Dataset/
└── <region>/                        # Selected mesh (e.g., skin061, skin224, skin256)
    ├── ci_001/                      # Initial concentration folder
    │   ├── nu_0.00000001.png        # One simulation (nu formatted with 8 decimals)
    │   ├── nu_0.00000002.png
    │   └── ...                      # More diffusion coefficients
    ├── ci_002/
    ├── ...
    ├── ci_100/
    ├── ci_001.zip                   # Optional compressed archive
    ├── ci_002.zip
    └── ...

📊 Data Volume

  • Total Images: $N_{c_i} \times N_{\nu}$ per region (e.g., $100 \times 900 = 90{,}000$ images/region)
  • Storage: Varies by mesh size and compression (typically several GB per full sweep)
  • Parameters: Initial concentration ($c_i$) and diffusion coefficient ($\nu$)
  • Resolution: Defined by the selected region mesh (e.g., $61 \times 61$, $224 \times 224$, $256 \times 256$ nodes)

🎯 Dataset Applications

Use Case Dataset Type Description
Machine Learning Training 🤖 Complete Dataset Large-scale image dataset per region (e.g., 90,000 images/region for a 100×900 sweep)
Parameter Studies 📈 Subset Analysis Specific parameter ranges
Validation Test Sets Independent validation data
Benchmarking 🏆 Reference Solutions Standard test cases

📈 Performance Benchmarks

⏱️ Execution Times

Mesh Size Nodes Time Steps JIT Solver Vectorized Solver Memory Usage
$224 \times 224$ 50,176 1,000 ~4.5s ~12.3s ~2.1 GB
$224 \times 224$ 50,176 10,000 ~45s ~123s ~2.1 GB
$256 \times 256$ 65,536 1,000 ~6.5s ~18.7s ~2.8 GB
$256 \times 256$ 65,536 10,000 ~65s ~187s ~2.8 GB

Benchmarks: Intel i7-8700K @ 3.70GHz, 32GB RAM, Python 3.9

🚀 Performance Optimizations

Optimization Speedup Description
Numba JIT 3-4x Just-in-time compilation of critical loops
Vectorization 2-3x NumPy array operations
Memory Layout 1.5x Contiguous array storage
Parallel Processing Nx Multi-core dataset generation

📊 Scalability Analysis

# Performance scaling with problem size
Nodes vs Time: O(N log N)     # Near-linear scaling
Memory vs Nodes: O(N)         # Linear memory usage
Parallel Efficiency: 85-90%   # Multi-core performance

🤝 Contributing

🌟 Contribute to the Project

Bug reports, feature requests, and pull requests are welcome

Issues Pull Requests

🐛 Bug Reports

  1. Search existing issues: Check if the bug has already been reported
  2. Create a detailed report: Include steps to reproduce and expected vs actual behavior
  3. Provide context: Operating system, Python version, and relevant parameters (mesh, $\nu$, $c_i$)

💡 Feature Requests

  1. Describe the feature: Clear and concise description of the proposed functionality
  2. Justify the need: Explain how it benefits research or reproducibility
  3. Provide examples: Use cases, expected inputs/outputs, and acceptance criteria

💻 Code Contributions

git clone https://github.com/yourusername/mGFD_Skin_Diffusion_Simulator.git
cd mGFD_Skin_Diffusion_Simulator

python -m venv dev_env
source dev_env/bin/activate  # On Windows: dev_env\Scripts\activate
pip install -r requirements.txt

git checkout -b feature/your-feature-name

🧑‍🔬 Research Team

🌟 Meet the Team

Researchers and graduate students advancing computational diffusion modeling

👥 Main Researchers

Photo Researcher Affiliation Contact
Dr. Gerardo Tinoco Guerrero Dr. Gerardo Tinoco Guerrero 🇲🇽
Numerical Methods & Computational Mathematics
Company: SIIIA MATH
University: UMSNH
Contact
ORCID 0000-0003-3119-770X
ResearchGate Profile
Dr. Francisco Javier Domínguez Mota Dr. Francisco Javier Domínguez Mota 🇲🇽
Applied Mathematics & Finite Difference Methods
Company: SIIIA MATH
University: UMSNH
Contact
ORCID 0000-0001-6837-172X
ResearchGate Profile
Dr. José Alberto Guzmán Torres Dr. José Alberto Guzmán Torres 🇲🇽
Engineering applications and Artificial Intelligence
Company: SIIIA MATH
University: UMSNH
Contact
ORCID 0000-0002-9309-9390
ResearchGate Profile
Dr. Heriberto Árias Rojas Dr. Heriberto Árias Rojas 🇲🇽
Engineering applications
Company: SIIIA MATH
University: UMSNH
Contact
ORCID 0000-0002-7641-8310
ResearchGate Profile

🎓 Ph.D. Research Students

Photo Student Institution Contact
Gabriela Pedraza-Jiménez Gabriela Pedraza-Jiménez
Ph.D. Research Student
University: UMSNH Contact
Eli Chagolla-Inzunza Eli Chagolla-Inzunza
Ph.D. Research Student
University: UMSNH Contact

🎓 M.Sc. Research Students

Photo Student Institution Contact
Jorge L. González-Figueroa Jorge L. González-Figueroa
M.Sc. Research Student
University: UMSNH Contact
Christopher N. Magaña-Barocio Christopher N. Magaña-Barocio
M.Sc. Research Student
University: UMSNH Contact

🎓 Undergraduate Research Students

Photo Student Institution Contact
Maria Goretti Fraga Lopez Maria Goretti Fraga-Lopez
Undergraduate Research Student
University: UMSNH Contact

🏭 Industry Partners Supporting Innovation

🌟 Industry Partners Supporting Innovation

Collaboration between academia and industry to accelerate real-world impact

🏭 SIIIA MATH

Soluciones de Ingeniería, México

Website Type Location

🎯 Focus areas:

  • Mathematical modeling & simulation
  • AI/ML engineering solutions
  • Technology transfer and applied R&D

Contact


📚 Scientific References

📚 Core Publications

  1. Tinoco-Guerrero, G., Domínguez-Mota, F. J., Guzmán-Torres, J. A., & Tinoco-Ruiz, J. G. (2022). "Numerical Solution of Diffusion Equation using a Method of Lines and Generalized Finite Differences." Revista Internacional de Métodos Numéricos para Cálculo y Diseño en Ingeniería, 38(2). DOI: 10.23967/j.rimni.2022.06.003

🏆 Research Achievements

  • Large-Scale Simulation Dataset: Configurable sweeps (e.g., 90,000 simulations per region mesh for a 100×900 sweep)
  • High-Performance Implementation: 3-4x speedup with Numba JIT optimization
  • Open Source Framework: MIT licensed for academic and commercial use
  • Cross-Platform Compatibility: Windows, Linux, macOS support

📝 Citation & License

If you use this software in your research, please cite:

@software{gfd_skin_simulator_2025,
  title={Skin Diffusion Simulator with GFD: High-Performance Computational Framework 
         for Biomedical Transport Modeling},
  author={Tinoco-Guerrero, Gerardo and 
          Domínguez-Mota, Francisco Javier and 
          Guzmán-Torres, José Alberto and
          Arias-Rojas, Heriberto},
  year={2025},
  institution={Universidad Michoacana de San Nicolás de Hidalgo},
  organization={SIIIA MATH: Soluciones en ingeniería},
  url={https://github.com/gstinoco/mGFD_Skin_Diffusion_Simulator},
  note={Advanced computational framework for skin diffusion modeling using 
        Generalized Finite Differences method}
}

📄 License

This project is licensed under the MIT License - see the full license text below:

MIT License

Copyright (c) 2025 Gerardo Tinoco-Guerrero, Francisco Javier Domínguez-Mota, 
                   José Alberto Guzmán-Torres, Heriberto Árias Rojas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Academic Use: This software is developed for research and educational purposes. Commercial use is permitted under the MIT License terms.


🙏 Acknowledgments

❤️ Special Thanks

We extend our gratitude to the institutions and partners supporting this research and open-source development

🏛️ Institutional Support

🎓 Universidad Michoacana de San Nicolás de Hidalgo (UMSNH)
Academic institution, Mexico

Website Type: University Support: Infrastructure

Key support
  • Academic foundation and research infrastructure
  • Scientific training and supervision environment
🏛️ Secretariat of Science, Humanities, Technology and Innovation(SECIHTI)
State Secretariat, Mexico

Website Type: Government Support: Funding and Innovation

Key support
  • Support for science and technology initiatives
  • Funding and innovation promotion
🌿 Centre Internacional de Mètodes Numèrics en Enginyeria (CIMNE)
Industry, Spain

Website Type: Research Center Support: Collaboration

Key support
  • International collaboration in numerical methods
  • Computational engineering research environment
🏭 SIIIA MATH: Soluciones en Ingeniería
Industry, México

Website Type: Industry Partner Support: Technology Transfer

Key support
  • Industry-driven applied research and development
  • Technology transfer and practical engineering impact

:building_with_garden: Research Centers & Collaborations

🌿 Aula CIMNE-Morelia
Research collaboration space

Website Area: Numerical Methods Collaboration: Applied Computing

Collaboration highlights
  • Numerical methods and computational engineering environment
  • Academic–industry collaboration and training activities
🎓 UMSNH
Academic collaboration

Website Type: University Support: Research Infrastructure

Collaboration highlights
  • Institutional infrastructure supporting research and training
  • Graduate formation and supervision for scientific computing

💻 Technology Communities

📦 Framework 👥 Community ⭐ Contribution
NumPy NumPy Community Array computing foundation
SciPy SciPy Community Numerical algorithms and I/O
Matplotlib Matplotlib Community Scientific visualization
Numba Numba Community High-performance Python
tqdm tqdm Community Progress monitoring

📧 Contact & Support

Contact channels, technical support, and collaboration opportunities

Issues Email

Primary Contact
Research group coordination

Dr. Gerardo Tinoco Guerrero
Morelia, Michoacán, México

Email Company: SIIIA MATH University: UMSNH
Technical Support
Bug reports, questions, and collaboration requests

Open an Issue Send Email Request Collaboration

  • Issues for bugs and feature requests
  • Email for technical inquiries
  • Collaboration for partnerships and joint projects
Collaboration Opportunities
Research and engineering partnerships

🩺 Biomedical Engineering
Transdermal delivery systems, medical device design
🤖 Machine Learning
Diffusion pattern analysis, predictive modeling
🧮 Numerical Methods
Discretization techniques, solver optimization
🧪 Clinical Research
Validation with experimental data, clinical applications
💊 Pharmaceutical Research
Drug delivery optimization, formulation studies
Student Opportunities
Projects and training in scientific computing

  • Graduate Programs: research opportunities with the team
  • Undergraduate Projects: thesis topics in computational biology
  • Internships: scientific computing and applied modeling
Institutional Affiliations

SIIIA MATH UMSNH Research Group

💬 FAQ

Which meshes are available?
Check region/ for skin*.mat files (e.g., skin061, skin224, skin256).
Where do results go?
python GFD_skin.py saves skin.png and skin2.png in the project root. Dataset generation saves outputs in Dataset/<region>/.
Can I use this in commercial projects?
Yes. The project is released under the MIT License.
How should I cite this work?
Use the BibTeX entry in the Citation section and the referenced DOI in Scientific References.

Advancing biomedical diffusion modeling through open-source collaboration

GitHub stars GitHub forks GitHub watchers


If this project helps your research, please consider giving it a star.

About

Open-source framework for transient 2D diffusion modeling in skin-like domains using the Generalized Finite Differences Method, featuring mesh libraries, visualization outputs, and large-scale dataset generation for machine learning and parameter studies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors