Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pysemitip: A Python Modernization of the SEMITIP STM Simulation Software

Overview

The primary goal of the Pysemitip project is to translate the original Fortran Semitip program, developed by R.M. Feenstra's group at Carnegie Mellon University (CMU), into a modern, maintainable, and extensible Python library. Semitip is a physics simulation tool designed for simulating Scanning Tunneling Microscopy (STM) measurement results.

The motivation behind this modernization effort is to facilitate further development, enhance maintainability, and enable seamless integration with the rich ecosystem of modern scientific Python tools and libraries.

Project Status

🎉 Phase 2 Complete: Full Physics Model Implementation with Fortran-Equivalent Accuracy

This project has successfully completed Phase 2 with a significant breakthrough: implementation of Fortran-equivalent tunneling current calculations that match the original SEMITIP's scientific accuracy.

Current Achievements

  • Phase 1: Complete numerical tools foundation (Golden Section optimization, Fermi-Dirac functions, interpolation)
  • Phase 2: Full physics models with Fortran-equivalent tunneling current calculator
  • Integration: Unified API supporting both simplified and research-grade calculations
  • Testing: 65+ comprehensive tests with 100% pass rate

Key Breakthrough: Fortran-Equivalent Tunneling Current

The project now includes a complete implementation of the Fortran intcurr-6.2.f functionality:

  • Complete 1D Schrödinger equation numerical integration
  • Full localized state search with node counting
  • 3D→1D potential expansion (POTEXPAND equivalent)
  • Multi-band treatment (VB light/heavy/split-off + CB)
  • Exact physical constants and integration methods

This represents a 4x improvement in feature completeness over simplified implementations.

Core Methodology

Our development is guided by the "Analyze First, Translate Second" philosophy. This means that before any Fortran code is translated into Python, a thorough understanding of its physical purpose and algorithmic structure is paramount.

This understanding is achieved by:

  1. Consulting the original physics papers and technical manuals located in the /docs/Fortran-semitip/ directory.
  2. Analyzing the structure and interdependencies within the original Fortran source code found in /src/fortran/.

This approach is crucial to avoid the pitfalls of superficial, line-by-line translation, ensuring accuracy and preserving the integrity of the underlying physical models.

Quick Start

Installation

# Clone the repository
git clone <repository_url>
cd Pysemitip

# Set up environment (choose one)
conda env create -f environment.yml && conda activate pysemitip
# OR
pip install -r requirements.txt

Basic Usage

from physics import create_tunneling_calculator, AccuracyLevel
from physics.materials import default_materials

# Get a material
material = default_materials.get_material("Si_n")

# Create calculator with desired accuracy
calculator = create_tunneling_calculator(AccuracyLevel.HIGH_ACCURACY)

# Simple calculation
from physics import calculate_tunneling_current_simple
current = calculate_tunneling_current_simple(
    material, bias_voltage=1.0, separation=1.0, 
    accuracy=AccuracyLevel.BALANCED
)
print(f"Tunneling current: {current:.2e} A")

Available Accuracy Levels

  • FAST: Speed-optimized simplified calculations
  • BALANCED: Good compromise between speed and accuracy
  • HIGH_ACCURACY: Full Fortran-equivalent precision
  • RESEARCH_GRADE: Maximum scientific accuracy with all features

Repository Structure

  • src/: The main source code directory.
    • physics/: Complete physics model implementations
      • materials.py: Semiconductor material database
      • charge_density.py: Fermi-Dirac statistics and charge calculations
      • poisson.py: 3D cylindrical coordinate Poisson solver
      • tunneling_current.py: Original simplified implementation
      • tunneling_current_fortran_equivalent.py: Full Fortran-equivalent calculator
      • tunneling_current_unified.py: Unified API with automatic method selection
    • utils/: Numerical tools (Golden Section, Fermi-Dirac, interpolation)
    • fortran/: Original Fortran source code for reference
    • core/: Legacy utility modules for file conversion
  • tests/: Comprehensive test suite (65+ tests)
    • test_physics_models.py: Core physics validation
    • test_fortran_equivalent_tunneling.py: Fortran compatibility tests
    • test_tunneling_integration.py: Unified API integration tests
  • demos/: Working examples and performance comparisons
  • docs/: Extensive documentation including development log and physics references
  • environment.yml / requirements.txt: Environment setup files

Development Setup

You can set up the Python development environment using either Conda or pip.

Using Conda (recommended):

  1. Create the Conda environment from the environment.yml file:
    conda env create -f environment.yml
  2. Activate the environment:
    conda activate pysemitip

Using pip:

  1. Install the required packages using requirements.txt:
    pip install -r requirements.txt

Current Implementation Status

✅ Phase 1: Numerical Foundation (Complete)

Comprehensive mathematical toolkit

  • Golden Section optimization (GSECT equivalent)
  • Fermi-Dirac statistics and integration functions
  • Multi-dimensional interpolation tools
  • Numerical differentiation and adaptive integration
  • Result: 23 tests passed, full Fortran numerical compatibility

✅ Phase 2: Physics Models (Complete)

Complete physics simulation capabilities

  • Materials Database: Si (n/p), GaAs (n), intrinsic semiconductors
  • Charge Density Calculator: Self-consistent Fermi level determination
  • Poisson Solver: 3D cylindrical coordinates for STM geometry
  • Tunneling Current: Both simplified AND Fortran-equivalent implementations
  • Result: 42 tests passed, research-grade accuracy achieved

🚧 Phase 3: Geometry & Grid Layer (Planned)

STM-specific geometry and visualization

  • 3D cylindrical grid management for STM geometry
  • Tip and sample geometry modeling
  • Potential and current density visualization
  • Integration with existing physics models

🔮 Phase 4: High-Level API & Applications (Future)

User-friendly simulation interface

  • Complete STM simulation workflows
  • Parameter optimization tools
  • Results analysis and comparison utilities
  • Integration with experimental data

Key Features

Unified Tunneling Current API

# Automatic method selection based on accuracy needs
from physics import create_tunneling_calculator, AccuracyLevel

# Fast screening calculations
calculator_fast = create_tunneling_calculator(AccuracyLevel.FAST)

# Research-grade Fortran-equivalent calculations  
calculator_research = create_tunneling_calculator(AccuracyLevel.RESEARCH_GRADE)

Multiple Calculation Methods

  • Simplified: Fast WKB approximation for rapid screening
  • Fortran-Equivalent: Complete Schrödinger integration with localized states
  • Auto-Selection: Intelligent method choice based on problem requirements

Comprehensive Validation

  • Full test suite with Fortran compatibility verification
  • Performance benchmarking and accuracy comparisons
  • Demonstration scripts with real physics examples

How to Contribute

Contributions to Pysemitip are welcome. To ensure the quality and integrity of the project, please adhere to the following guidelines:

  • Follow the Core Methodology: Prioritize understanding the physics and original code structure before translation.
  • Structured Translation: Contribute by translating individual subroutines and providing corresponding unit tests.
  • Documentation: All new code, architectural decisions, and significant findings must be clearly documented.
  • Code Quality: Ensure your code is clean, well-commented, and adheres to Python best practices (e.g., PEP 8).
  • Testing: All contributions must be accompanied by relevant tests.

By following these principles, we aim to create a robust, accurate, and valuable Python library for the STM research community.

About

拍謝 My tip

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages