Metadata-Version: 2.4
Name: pycphy
Version: 0.1.0
Summary: Python: Computational Physics - Tools for physics dynamics simulation
Home-page: https://github.com/SanjeevBashyal/pycphy
Author: Sanjeev Bashyal
Author-email: Sanjeev Bashyal <sanjeev.bashyal@example.com>
Maintainer-email: Sanjeev Bashyal <sanjeev.bashyal@example.com>
License: MIT
Project-URL: Homepage, https://github.com/SanjeevBashyal/pycphy
Project-URL: Repository, https://github.com/SanjeevBashyal/pycphy
Project-URL: Documentation, https://github.com/SanjeevBashyal/pycphy#readme
Project-URL: Bug Tracker, https://github.com/SanjeevBashyal/pycphy/issues
Keywords: computational physics,simulation,openfoam,cfd,physics
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.19.0
Requires-Dist: scipy>=1.6.0
Requires-Dist: matplotlib>=3.3.0
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# pycphy

**Python: Computational Physics**

A comprehensive Python package for computational physics simulations and tools, with a focus on OpenFOAM case development and management.

**Author:** Sanjeev Bashyal  
**Repository:** [https://github.com/SanjeevBashyal/pycphy](https://github.com/SanjeevBashyal/pycphy)

## Overview

`pycphy` is a Python package designed to provide tools and utilities for computational physics simulations. The package currently includes the `foamCaseDeveloper` module, which offers comprehensive tools for creating and managing OpenFOAM CFD simulation cases.

## Features

### foamCaseDeveloper Module

The `foamCaseDeveloper` module provides:

- **BlockMesh Generation**: Create OpenFOAM blockMeshDict files with custom geometries
- **Control Dictionary Setup**: Configure solver settings, time control, and output parameters
- **Turbulence Model Configuration**: Set up RAS, LES, and laminar turbulence models
- **Complete Case Management**: Automatically create complete OpenFOAM case directories
- **Validation and Error Checking**: Built-in validation for all configuration parameters

## Installation

### From Source

```bash
git clone https://github.com/SanjeevBashyal/pycphy.git
cd pycphy
pip install -e .
```

### Development Installation

```bash
git clone https://github.com/SanjeevBashyal/pycphy.git
cd pycphy
pip install -e ".[dev]"
```

## Quick Start

### Using the Command Line Interface

```bash
# Create an example case
pycphy-foam --example

# Create a custom case from configuration files
pycphy-foam --case myCase --geometry configBlockMesh.py --control configControl.py --turbulence configTurbulence.py
```

### Using Python API

```python
from pycphy.foamCaseDeveloper import FoamCaseManager, BlockMeshConfig, ControlConfig, TurbulenceConfig

# Create a case manager
case_manager = FoamCaseManager("myCase")

# Set up geometry
geometry_config = BlockMeshConfig(
    p0=(0.0, 0.0, 0.0),
    p1=(1.0, 1.0, 1.0),
    cells=(50, 50, 50),
    patch_names={
        'minX': 'inlet',
        'maxX': 'outlet',
        'minY': 'frontWall',
        'maxY': 'backWall',
        'minZ': 'floor',
        'maxZ': 'ceiling'
    }
)

case_manager.setup_geometry(
    p0=geometry_config.p0,
    p1=geometry_config.p1,
    cells=geometry_config.cells,
    patch_names=geometry_config.patch_names
)

# Set up control
control_config = ControlConfig()
control_config.set_solver("interFoam")
control_config.set_time_control(start_time=0, end_time=1.0, delta_t=0.001)

case_manager.setup_control(control_config.get_parameters())

# Set up turbulence
turbulence_config = TurbulenceConfig("RAS")
turbulence_config.set_ras_model("kOmegaSST")

case_manager.setup_turbulence(
    simulation_type=turbulence_config.get_simulation_type(),
    model_properties=turbulence_config.get_model_properties()
)

# Create the complete case
case_manager.create_full_case()
```

## Package Structure

```
pycphy/
├── __init__.py
└── foamCaseDeveloper/
    ├── __init__.py
    ├── main.py                    # Command-line interface
    ├── core/                      # Core functionality
    │   ├── __init__.py
    │   ├── foam_case_manager.py   # Main case management class
    │   ├── block_mesh_developer.py # BlockMesh generation
    │   ├── control_dict_writer.py  # Control dictionary writer
    │   └── turbulence_properties_writer.py # Turbulence properties writer
    ├── writers/                   # OpenFOAM dictionary writers
    │   ├── __init__.py
    │   ├── foam_writer.py         # Base writer class
    │   ├── block_mesh_writer.py   # BlockMesh dictionary writer
    │   ├── control_dict_writer.py # Control dictionary writer
    │   └── turbulence_properties_writer.py # Turbulence properties writer
    └── config/                    # Configuration classes
        ├── __init__.py
        ├── block_mesh_config.py   # Geometry configuration
        ├── control_config.py      # Control configuration
        └── turbulence_config.py   # Turbulence configuration
```

## Configuration

### Geometry Configuration (BlockMesh)

```python
from pycphy.foamCaseDeveloper import BlockMeshConfig

config = BlockMeshConfig(
    p0=(0.0, 0.0, 0.0),      # Minimum corner
    p1=(1.0, 1.0, 1.0),      # Maximum corner
    cells=(50, 50, 50),      # Number of cells
    patch_names={            # Boundary patch names
        'minX': 'inlet',
        'maxX': 'outlet',
        'minY': 'frontWall',
        'maxY': 'backWall',
        'minZ': 'floor',
        'maxZ': 'ceiling'
    }
)
```

### Control Configuration

```python
from pycphy.foamCaseDeveloper import ControlConfig

config = ControlConfig()
config.set_solver("interFoam")
config.set_time_control(start_time=0, end_time=1.0, delta_t=0.001)
config.set_write_control(write_interval=0.05)
config.set_courant_control(max_co=1)
```

### Turbulence Configuration

```python
from pycphy.foamCaseDeveloper import TurbulenceConfig

# RAS configuration
ras_config = TurbulenceConfig("RAS")
ras_config.set_ras_model("kOmegaSST")

# LES configuration
les_config = TurbulenceConfig("LES")
les_config.set_les_model("kEqn")
les_config.set_delta_model("smooth")

# Laminar configuration
laminar_config = TurbulenceConfig("laminar")
```

## Examples

### Channel Flow Case

```python
from pycphy.foamCaseDeveloper import FoamCaseManager, BlockMeshConfig, ControlConfig, TurbulenceConfig

# Create channel flow case
case_manager = FoamCaseManager("channelFlow")

# Channel geometry: 0.5m x 0.2m x 0.1m
geometry = BlockMeshConfig(
    p0=(0.0, 0.0, 0.0),
    p1=(0.5, 0.2, 0.1),
    cells=(50, 20, 50),
    patch_names={
        'minX': 'inlet',
        'maxX': 'outlet',
        'minY': 'frontWall',
        'maxY': 'backWall',
        'minZ': 'floor',
        'maxZ': 'ceiling'
    }
)

case_manager.setup_geometry(
    p0=geometry.p0, p1=geometry.p1, cells=geometry.cells,
    patch_names=geometry.patch_names
)

# Set up solver
control = ControlConfig()
control.set_solver("interFoam")
control.set_time_control(start_time=0, end_time=1.0, delta_t=0.001)

case_manager.setup_control(control.get_parameters())

# Set up turbulence
turbulence = TurbulenceConfig("RAS")
turbulence.set_ras_model("kOmegaSST")

case_manager.setup_turbulence(
    simulation_type=turbulence.get_simulation_type(),
    model_properties=turbulence.get_model_properties()
)

# Create the case
case_manager.create_full_case()
```

## Requirements

- Python >= 3.7
- NumPy >= 1.19.0
- SciPy >= 1.6.0
- Matplotlib >= 3.3.0

## Development

### Running Tests

```bash
pytest
```

### Code Formatting

```bash
black pycphy/
flake8 pycphy/
```

### Building Documentation

```bash
sphinx-build docs/ docs/_build/
```

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/new-feature`)
3. Commit your changes (`git commit -am 'Add new feature'`)
4. Push to the branch (`git push origin feature/new-feature`)
5. Create a Pull Request

## License

This project is licensed under the MIT License - see the LICENSE file for details.

## Citation

If you use pycphy in your research, please cite:

```bibtex
@software{bashyal2025pycphy,
  title={pycphy: Python Computational Physics},
  author={Bashyal, Sanjeev},
  year={2025},
  url={https://github.com/SanjeevBashyal/pycphy}
}
```

## Support

For questions, issues, or contributions, please visit the [GitHub repository](https://github.com/SanjeevBashyal/pycphy).
