Skip to main content

CLI utility to edit and run a ddscat.par file for DDSCAT

Project description

ddscatcli

DOI PyPI

This script is a command-line utility to edit and run a ddscat.par file for DDSCAT in a reproducible and automated way.

It allows you to:

  • Modify parameters inside a single ddscat.par configuration file (shape, solver, FFT method, dielectric files, wavelength, etc.).
  • Run DDSCAT automatically — serial, MPI, or OpenMP.
  • Create timestamped backups of the original ddscat.par file.
  • Uses environment variables for configuration (no code editing).

Configuration

ddscatcli resolves ddscat.par in this order:

  1. $DDSCAT_PAR (absolute path recommended; relative paths are interpreted relative to your current working directory)
  2. ddscat.par (current working directory)

ddscatcli resolves the DDSCAT executable in this order:

  1. $DDSCAT_EXE (absolute path recommended; relative paths are interpreted relative to your current working directory)
  2. ddscat (current working directory)
  3. ddscat found on your PATH

Example:

export DDSCAT_PAR=/abs/path/to/ddscat.par
export DDSCAT_EXE=/abs/path/to/ddscat

Installation

Install from PyPI:

pip install ddscatcli

This installs the ddscatcli command globally. If you prefer to keep it isolated in a virtual environment:

python -m venv .venv
source .venv/bin/activate   # on Linux/macOS
# .venv\Scripts\activate    # on Windows

pip install ddscatcli

Requirements

  • Python 3.8>=
  • Standard library only

Usage

  1. Get help and options:

    ddscatcli -h
    
  2. List available shapes:

    ddscatcli -CSHAPE -h
    
  3. Run modes:

    • -dry-run → preview the edits only (no file modification).
    • (no flag) → apply edits to ddscat.par.
    • -run → apply edits and automatically run DDSCAT.
  4. Parallel options:

    • -omp-threads N → set the number of OpenMP threads.
    • -mpi [launcher] -np N → run DDSCAT with MPI (e.g. mpirun, mpiexec, srun).

Examples

Preview edits without modifying:

ddscatcli -CSHAPE ANIRCTNGL -dry-run

Change the shape and run immediately:

ddscatcli -CSHAPE ELLIPSOID -SHPAR "16 8 4" -run

Set OpenMP threads:

ddscatcli -omp-threads 16 -run

You can repeat -DIEL once per material:

ddscatcli -NCOMP 3 -DIEL diel1.txt -DIEL diel2.txt -DIEL diel3.txt

Or provide them in a single flag:

ddscatcli -NCOMP 3 --diels diel1.txt diel2.txt diel3.txt

Note: if -NCOMP is provided, the number of dielectric entries must match NCOMP exactly.


Use from Python

ddscatcli exposes a run function.

import os
import ddscatcli

os.environ["DDSCAT_PAR"] = "/abs/path/to/ddscat.par"
os.environ["DDSCAT_EXE"] = "/abs/path/to/ddscat"

ddscatcli.run(["-dry-run", "-CSHAPE", "ELLIPSOID"])

Backups

Every modification automatically creates a timestamped backup:

ddscat.par.bak.YYYYMMDD-HHMMSS

Notes

  • Each parameter is matched using its identifying keyword in the ddscat.par file.
  • Supports dielectric and shape overrides via -DIEL, -NCOMP, -SHPAR, etc.
  • DDSCAT must be compiled and installed separately — this tool just wraps it.

License

This project is licensed under the GNU General Public License v3.0 (GPLv3). You are free to use, modify, and share it under the same license.


Citation

If you use ddscatcli, please cite:

Clément Argentin, ddscatcli (2025).
DOI: 10.5281/zenodo.17493074

You can click the “Cite this repository” button on the right-hand side of the GitHub page for citation formats (BibTeX, APA, etc.).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ddscatcli-1.0.2.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ddscatcli-1.0.2-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file ddscatcli-1.0.2.tar.gz.

File metadata

  • Download URL: ddscatcli-1.0.2.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ddscatcli-1.0.2.tar.gz
Algorithm Hash digest
SHA256 b3b83451649b8d70e847f3f9a8f08ff9490c9410806b9fac4d078e061aeb1c02
MD5 a289c66a7723991e73dbb289fe56efd7
BLAKE2b-256 bdce2c7831a16b677704ceed3d2c882e0d423ea27ab814be6f9f1e82c667d6ce

See more details on using hashes here.

File details

Details for the file ddscatcli-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: ddscatcli-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for ddscatcli-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bf0f57ab0057ef8ebce256a60ecf5ee7a09c7ae8c9420d4e5c7387c952441e31
MD5 74545981f73dd6d89dfb8f4e554f8976
BLAKE2b-256 850144bced3a8ba3720f9228561871401f730c82f69f3c061ebd71b802cf1880

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page