A catenary calculator using the Newton-Raphson method for precision engineering calculations.
Author: kito129 Version: 1.1.0 Created: 2023/10/18 Last Update: 2025/09/02
A command-line application for calculating catenary parameters using the Newton-Raphson numerical method. The calculator provides precise results for cable sag and tension calculations in engineering applications.
Features:
- Interactive command-line interface with input validation
- Default parameter set for quick calculations
- Newton-Raphson method for high precision
- Support for custom parameter input
- Comprehensive development environment with modern Python tooling
Usage:
- Run with
make runorpython main.py - Choose 'y' to input custom parameters or 'n' to use default values
- Results include parameter calculations and arrow measurements
- Python 3.13 or higher
- Make (for running Makefile commands)
-
Clone the repository
git clone https://github.com/kito129/catenaryCalculator.git cd catenaryCalculator -
Quick setup with make (recommended)
make setup
This will create the virtual environment, install uv, sync dependencies, and setup pre-commit hooks.
-
Manual setup (alternative)
a. Create and activate a Python virtual environment
make venv source .venv/bin/activate # On macOS/Linux # or .venv\Scripts\activate # On Windows
b. Install uv for package management
pip install uv
c. Initialize and sync dependencies with uv
# Initialize uv project (if not already done) uv init # Sync dependencies from pyproject.toml uv sync # Or sync with development dependencies uv sync --dev
d. Add development tools using uv
uv add --dev flake8 pre-commit pytest ruff black
e. Setup pre-commit hooks
pre-commit install
make venv- Create Python virtual environmentmake venv-clean- Remove Python virtual environmentmake setup- Setup development environment (includes venv)make install- Install/sync dependenciesmake run- Run the main applicationmake test- Run testsmake lint- Run lintingmake format- Format codemake check- Run all checks (lint + test)make clean- Clean up temporary filesmake add PACKAGE=name- Add dependencymake add-dev PACKAGE=name- Add dev dependencymake remove PACKAGE=name- Remove dependencymake update- Update dependenciesmake lock- Create/update lock filemake uv-run CMD='command'- Run any command in project environmentmake commit- Create a conventional commit using commitizenmake bump-patch- Bump patch version (1.1.0 -> 1.1.1)make bump-minor- Bump minor version (1.1.0 -> 1.2.0)make bump-major- Bump major version (1.1.0 -> 2.0.0)
This project uses uv for fast and reliable package management. Key features:
- Fast dependency resolution and installation
- Lock file support for reproducible builds
- Compatible with pip and standard Python packaging
Code quality is maintained using flake8. Configuration is in .flake8 file.
Run linting with:
make lint
# or
flake8 .Pre-commit hooks ensure code quality before commits:
- Flake8 linting
- Code formatting
- Import sorting
- Trailing whitespace removal
- Commit message validation (Conventional Commits format)
Hooks run automatically on git commit, or manually with:
pre-commit run --all-filesThis project follows Semantic Versioning and Conventional Commits.
Commit Message Format:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, etc.)refactor: Code refactoringperf: Performance improvementstest: Adding/updating testschore: Build process or auxiliary tool changes
Examples:
# Use commitizen for guided commits
make commit
# Manual examples
git commit -m "feat: add Newton-Raphson iteration limit"
git commit -m "fix: resolve calculation precision error"
git commit -m "docs: update API documentation"Version Bumping:
make bump-patch # 1.1.0 -> 1.1.1 (bug fixes)
make bump-minor # 1.1.0 -> 1.2.0 (new features)
make bump-major # 1.1.0 -> 2.0.0 (breaking changes)