
Modular
Flexible, composable models that allow for customization and experimentation. Easily extend with your own models, submodels, and constraints.

Built on PyTorch
Leverage GPU acceleration and automatic differentiation for fast, efficient parameter estimation. Fit hundreds of curves simultaneously with complex models (10+ parameters) using state-of-the-art optimization.

Comprehensive
Unified framework for extracting model parameters from data across domains of leaf gas exchange, hydraulics, and optics all in one toolkit.
References
PhoTorch: a robust and generalized biochemical photosynthesis model fitting package based on PyTorch
@article{lei2025photorch,
  title={PhoTorch: a robust and generalized biochemical photosynthesis model fitting package based on PyTorch},
  author={Lei, Tong and Rizzo, Kyle T and Bailey, Brian N},
  journal={Photosynthesis Research},
  volume={163},
  number={2},
  pages={21},
  year={2025},
  publisher={Springer}
}Get Started
1. Install PhyTorch:
pip install phytorch-libAll dependencies (PyTorch, NumPy, SciPy, Pandas, Matplotlib) are automatically installed.
2. Fit any model with the unified API:
from phytorch import fit
from phytorch.models.photosynthesis import FvCB
import pandas as pd
# Load your A-Ci curve data
df = pd.read_csv('aci_data.csv')
# Prepare data dictionary
data = {
    'Ci': df['Ci'].values,
    'Q': df['PARi'].values,
    'Tleaf': df['Tleaf'].values,
    'A': df['Photo'].values
}
# Fit the model (that's it!)
result = fit(FvCB(), data)
# View results
print(f"Vcmax25: {result.parameters['Vcmax25']:.2f}")
print(f"Jmax25: {result.parameters['Jmax25']:.2f}")
print(f"R² = {result.r_squared:.4f}")
# Plot comprehensive results (1:1, response curves, 3D surfaces)
result.plot()