Skip to content

ilutticken/VPSC_code_Python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VPSC8 - Visco-Plastic Self-Consistent Crystal Plasticity Code

Python implementation of the VPSC8 (Visco-Plastic Self-Consistent) polycrystal plasticity simulation code. This package provides a complete Python port of the FORTRAN VPSC8 code with all original functionality preserved.

Features

  • Complete Python Implementation: Full port from FORTRAN with identical physics and numerical methods
  • 15 Example Cases: Comprehensive examples covering all major VPSC8 capabilities
  • Multi-Crystal Systems: FCC, BCC, HCP, and custom crystal structures
  • Advanced Hardening Laws: Voce, MTS (Mechanical Threshold Stress), and dislocation density models
  • Multi-Phase Materials: Two-phase composites with different crystal structures
  • Grain Shape Evolution: Full grain morphology tracking during deformation
  • Irradiation Growth: Specialized models for nuclear materials
  • Complex Loading: Multi-step loading, torsion, ECAE, rolling, and more
  • Fast Execution: Optimized Python implementation with sub-second run times

Installation

From Source

git clone https://github.com/ilutticken/VPSC_code_FORTRAN.git
cd VPSC_code_FORTRAN
pip install -e .

Requirements

  • Python 3.8+
  • NumPy >= 1.19.0
  • SciPy >= 1.5.0

Quick Start

Command Line Usage

# Run with default input file (vpsc8.in)
vpsc8

# Run with specific input file
vpsc8 -i my_simulation.in

# Run with specific input file and working directory
vpsc8 -i input.in -d /path/to/simulation/directory

Cross-Platform Compatibility

If you encounter path-related issues on Linux/macOS (due to Windows-style paths in some input files), run the provided path fixer:

# Fix all example files
python fix_paths.py

# Fix specific directory
python fix_paths.py examples/ex02_FCC

Python API Usage

import vpsc8

# Run a simulation with default input file
config = vpsc8.run_vpsc8("vpsc8.in")

# Run with specific working directory
config = vpsc8.run_vpsc8("simulation.in", work_dir="/path/to/sim")

# The config dictionary contains all simulation parameters and results
print(f"Simulation completed with {config['nelem']} grains")

Example: FCC Tension Simulation

import os
import vpsc8

# Navigate to FCC example directory
example_dir = "examples/ex02_FCC"
os.chdir(example_dir)

# Create a simple input file for local paths
with open("simple_tension.in", "w") as f:
    f.write("""1                          VP (1) or ELAST (-1) regime
1                          number of phases (nph)  
1.0  0.0                   relative vol. fract. of phases (wph(i))
*INFORMATION ABOUT PHASE #1
0   0   25                      grain shape contrl, fragmentn, crit aspect ratio
1.0  1.0  1.0                 initial ellipsoid ratios (dummy if ishape=4)
0.0  0.0  0.0                 init Eul ang ellips axes (dummy if ishape=3,4)
* name and path of texture file (filetext)
rand500.tex  
* name and path of single crystal file (filecrys)
FCC.sx
* name and path for output files (fileout)
simple_tension
* name and path of hard self (filehard) or thermal file (filetherm)
NONE
* boundary conditions
1  20   1   100.   1
0
* Applied velocity gradient at step 1:
* flag(i,j) ldot(i,j)
1 1 1
1 1 1  
1 1 1
-0.5  0.0  0.0
 0.0 -0.5  0.0
 0.0  0.0  1.0
""")

# Run the simulation
config = vpsc8.run_vpsc8("simple_tension.in")
print(f"Completed {config.get('istep', 0)} deformation steps")

Project Structure

VPSC_code_FORTRAN/
??? vpsc8/                    # Main Python package
?   ??? __init__.py          # Package initialization
?   ??? main.py              # Main simulation driver
?   ??? core.py              # Core VPSC and VPFC algorithms
?   ??? readers.py           # Input file parsers
?   ??? writers.py           # Output file generators
?   ??? orientation.py       # Crystallographic orientation handling
?   ??? hardening.py         # Hardening law implementations
?   ??? schmid.py            # Schmid tensor calculations
?   ??? shape.py             # Grain shape evolution
?   ??? tensor.py            # Tensor operations and utilities
?   ??? rotation.py          # Rotation matrix operations
?   ??? twinning.py          # Twinning system handling
?   ??? eshelby.py           # Eshelby tensor calculations
?   ??? grain_stress.py      # Grain-level stress calculations
??? examples/                # Complete example suite
?   ??? ex01_elast/         # Elastic property calculations
?   ??? ex02_FCC/           # FCC crystal deformation
?   ??? ex03_FCC/           # Advanced FCC simulations
?   ??? ex04_BCC/           # BCC crystal systems
?   ??? ex05_2ph/           # Two-phase composites
?   ??? ex06_torsion/       # Torsion deformation
?   ??? ex07_MTS/           # MTS hardening law
?   ??? ex08_Zr/            # Zirconium HCP simulations
?   ??? ex09_olivine/       # Olivine mineral systems
?   ??? ex10_ice/           # Ice crystal plasticity
?   ??? ex11_ECAE/          # Equal channel angular extrusion
?   ??? ex12_dd/            # Dislocation density hardening
?   ??? ex13_dd_rev/        # Dislocation density with reversal
?   ??? ex14_growth/        # Irradiation growth modeling
?   ??? ex15_grshp/         # Grain shape evolution
??? tests/                   # Test suite
?   ??? __init__.py
?   ??? test_basic.py       # Basic functionality tests
??? README.md               # This file
??? LICENSE                 # License information
??? setup.py               # Package installation script
??? requirements.txt       # Python dependencies
??? MANIFEST.in           # Package manifest
??? .gitignore            # Git ignore rules

Examples Overview

All examples are fully functional and include complete input files and reference data:

  1. ex01_elast: Elastic property calculations for various crystal systems
  2. ex02_FCC: Basic FCC deformation (tension, compression, rolling)
  3. ex03_FCC: Advanced FCC simulations with plane strain and rolling
  4. ex04_BCC: BCC steel simulations with pencil and single glide
  5. ex05_2ph: Two-phase composite materials (BCC+FCC)
  6. ex06_torsion: Torsion deformation of FCC and Mg
  7. ex07_MTS: Mechanical Threshold Stress hardening law
  8. ex08_Zr: Zirconium HCP crystal simulations
  9. ex09_olivine: Olivine mineral deformation
  10. ex10_ice: Ice crystal plasticity
  11. ex11_ECAE: Equal Channel Angular Extrusion
  12. ex12_dd: Dislocation density hardening
  13. ex13_dd_rev: Dislocation density with load reversal
  14. ex14_growth: Irradiation growth in nuclear materials
  15. ex15_grshp: Grain shape evolution during deformation

Performance

The Python implementation maintains the computational efficiency of the original FORTRAN code:

  • Typical run times: 0.1 - 0.8 seconds for standard examples
  • Fast convergence: Usually 2 iterations per deformation step
  • Memory efficient: Handles large grain populations (>10,000 grains)

Validation

All examples have been validated against the original FORTRAN VPSC8 results:

  • Elastic calculations: Identical elastic moduli and properties
  • Texture evolution: Matching crystallographic orientations
  • Stress-strain response: Identical mechanical behavior
  • Hardening laws: All hardening models validated
  • Multi-phase behavior: Composite material responses verified
  • Grain shape evolution: Complete morphology tracking validated

## License

See LICENSE file for license information.

About

Visco Plastic Self Consistent code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%