Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/check_commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Check code quality of latest commit.
name: Check commit

on: [push, pull_request, workflow_dispatch]

jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
python:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:

- name: Check out code.
uses: actions/checkout@v5

- name: Install Python.
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}

- name: Install UV.
uses: astral-sh/setup-uv@v7

- name: Install package.
run: uv sync

- name: Lint code.
run: uv run ruff check

- name: Check types.
run: uv run basedpyright

- name: Run tests.
run: uv run tools/run_tests.py config
# We only run the very small part of the test suite that doesn't
# require Comsol to be installed. This essentially just tests that
# the library can be successfully imported, but not much more.
54 changes: 54 additions & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Publish new GitHub release on PyPI.
name: Publish release

on: [workflow_dispatch]

jobs:

build:
name: Build wheel
runs-on: ubuntu-latest
steps:

- name: Check out code.
uses: actions/checkout@v5

- name: Install Python.
uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: Install UV.
uses: astral-sh/setup-uv@v7

- name: Build wheel.
run: uv build --wheel --out-dir build/wheel

- name: Store wheel.
uses: actions/upload-artifact@v4
with:
name: python-wheel
path: build/wheel


publish:
name: Publish to PyPI
needs:
- build
if: startsWith(github.ref, 'refs/tags/') # Commit must be tagged.
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/MPh
permissions:
id-token: write
steps:

- name: Download wheel.
uses: actions/download-artifact@v5
with:
name: python-wheel
path: build/wheel

- name: Publish to PyPI.
uses: pypa/gh-action-pypi-publish@release/v1
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Build artifacts
build/
**/__pycache__
__pycache__/
uv.lock

# Test artifacts
**/.pytest_cache
tests/MPh.ini
.coverage
coverage.xml
.pytest_cache/
.ruff_cache/
*.mph.lock

# OS cruft
Thumbs.db
Expand Down
32 changes: 16 additions & 16 deletions PyPI.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
*Pythonic scripting interface for Comsol Multiphysics*

[Comsol] is a commercial software application that is widely used in
science and industry for research and development. It excels at modeling
almost any (multi-)physics problem by solving the governing set of
partial differential equations via the finite-element method. It comes
with a modern graphical user interface to set up simulation models and
can be scripted from Matlab or its native Java API.
[Comsol] is a commercial software application that is widely used in science
and industry for research and development. It excels at modeling almost any
(multi-)physics problem by solving the governing set of partial differential
equations via the finite-element method. It comes with a modern graphical user
interface to set up simulation models and can be scripted from Matlab or its
native Java API.

MPh brings the dearly missing power of Python to the world of Comsol.
It leverages the Java bridge provided by [JPype] to access the Comsol
API and wraps it in a layer of pythonic ease-of-use. The Python wrapper
covers common scripting tasks, such as loading a model from a file,
modifying parameters, importing data, to then run the simulation,
evaluate the results, and export them.
MPh brings the dearly missing power of Python to the world of Comsol. It
leverages the Java bridge provided by [JPype] to access the Comsol API and
wraps it in a layer of pythonic ease-of-use. The Python wrapper covers common
scripting tasks, such as loading a model from a file, modifying parameters,
importing data, to then run the simulation, evaluate the results, and export
them.

Comsol models are marked by their `.mph` file extension, which stands
for multi-physics. Hence the name of this library. It is open-source
and in no way affiliated with Comsol Inc., the company that develops
and sells the simulation software.
Comsol models are marked by their `.mph` file extension, which stands for
multi-physics. Hence the name of this library. It is open-source and in no way
affiliated with Comsol Inc., the company that develops and sells the simulation
software.

Find the full [documentation on Read-the-Docs][docs].

Expand Down
33 changes: 17 additions & 16 deletions ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# MPh
*Pythonic scripting interface for Comsol Multiphysics*

[Comsol] is a commercial software application that is widely used in
science and industry for research and development. It excels at modeling
almost any (multi-)physics problem by solving the governing set of
partial differential equations via the finite-element method. It comes
with a modern graphical user interface to set up simulation models and
can be scripted from Matlab or its native Java API.
[Comsol] is a commercial software application that is widely used in science
and industry for research and development. It excels at modeling almost any
(multi-)physics problem by solving the governing set of partial differential
equations via the finite-element method. It comes with a modern graphical user
interface to set up simulation models and can be scripted from Matlab or its
native Java API.

MPh brings the dearly missing power of Python to the world of Comsol.
It leverages the Java bridge provided by [JPype] to access the Comsol
API and wraps it in a layer of pythonic ease-of-use. The Python wrapper
covers common scripting tasks, such as loading a model from a file,
modifying parameters, importing data, to then run the simulation,
evaluate the results, and export them.
MPh brings the dearly missing power of Python to the world of Comsol. It
leverages the Java bridge provided by [JPype] to access the Comsol API and
wraps it in a layer of pythonic ease-of-use. The Python wrapper covers common
scripting tasks, such as loading a model from a file, modifying parameters,
importing data, to then run the simulation, evaluate the results, and export
them.

Comsol models are marked by their `.mph` file extension, which stands for
multi-physics. Hence the name of this library. It is open-source and in no way
affiliated with Comsol Inc., the company that develops and sells the simulation
software.

Comsol models are marked by their `.mph` file extension, which stands
for multi-physics. Hence the name of this library. It is open-source
and in no way affiliated with Comsol Inc., the company that develops
and sells the simulation software.

Find the full [documentation on Read-the-Docs][docs].

Expand Down
4 changes: 2 additions & 2 deletions demos/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Demonstration scripts

The scripts here demonstrate simple use cases and are referenced in
the "Demonstrations" chapter of the documentation.
The scripts here demonstrate simple use cases and are referenced in the
"Demonstrations" chapter of the documentation.
6 changes: 3 additions & 3 deletions demos/compact_models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Compacts Comsol models in the working directory.

Loads each Comsol model (`.mph` file) in the current folder, removes
solution and mesh data, resets the modeling history, then saves the
model file under its original name, effectively compacting its size.
Loads each Comsol model (`.mph` file) in the current folder, removes solution
and mesh data, resets the modeling history, then saves the model file under its
original name, effectively compacting its size.
"""

import mph
Expand Down
11 changes: 5 additions & 6 deletions demos/worker_pool.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""
Distributes a parameter sweep over multiple worker processes.

This demonstration works around the limitation that only a single
Comsol client can run inside one Python process. It leverages the
`multiprocessing` module from Python's standard library to create
several independent subprocesses ("workers") that communicate with
the parent process ("boss") via inter-process queues to pass job
instructions and results back and forth.
This demonstration works around the limitation that only a single Comsol client
can run inside one Python process. It leverages the `multiprocessing` module
from Python's standard library to create several independent subprocesses
("workers") that communicate with the parent process ("boss") via inter-process
queues to pass job instructions and results back and forth.
"""

import mph # Comsol interface
Expand Down
6 changes: 3 additions & 3 deletions docs/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Documentation source

The documentation hosted on Read-the-Docs is built from this folder.
The start page corresponds to `index.md`. The build process is
configured in `.readthedocs.yaml` in the project root folder.
The documentation hosted on Read-the-Docs is built from this folder. The start
page corresponds to `index.md`. The build process on Read-the-Docs is
configured in `.readthedocs.yaml`.
Loading