Skip to main content

Python tools for research at the Maha Fluid Power Research Center

Project description

MahaUtils

CI/CD codecov Documentation Status PyPI - Downloads

Overview

MahaUtils provides a collection of Python tools to support research work at the Maha Fluid Power Research Center at Purdue University. The classes, functions, and other objects in this package are intended to assist with general-purpose research tasks as well as simplify interaction with the Maha Multics software.

Warning The MahaUtils source code and documentation refers to the "Maha Multics" software in a number of places. The "Maha Multics" software is NOT related to the Multics operating system. It is an unrelated fluid simulation software designed for analyzing hydraulic pumps and motors.

Most of the tools in this package were originally separate scripts, written by Nathan Hess during various research work. They were combined into a single Python package as a way to reduce duplicate code, ensure these "utility scripts" were tested and robust, and make it easier to share the code.

Installation

The recommended way to install MahaUtils is through pip:

pip install mahautils

For more information about configuring Python and using packages, refer to the official Python documentation on setting up Python and installing packages.

Usage and Documentation

Detailed documentation for the MahaUtils project can be found here: https://mahautils.readthedocs.io.

The project documentation contains example code, file format specifications, and detailed API reference. If you're still not certain how to do something after reading it, feel free to create a discussion post!

Feature Highlights

SimViewer GUI

The MahaUtils package includes an interactive tool for plotting and exploring Maha Multics simulation results. SimViewer runs in a web browser, so it is compatible with nearly any operating system and platform.

Once you've installed the MahaUtils package, simply open a terminal and launch SimViewer by running:

$ SimViewer

:test_tube: Try It Out!

Want to give the GUI a try? The quickest way is to launch a GitHub Codespaces instance:

Open in GitHub Codespaces

If you need some files to experiment with, give these a try: sim_results_underdamped.txt and sim_results_overdamped.txt

The primary aim of the SimViewer GUI is to provide a visually-appealing, configurable interface for quickly reviewing and comparing simulation results, with sufficient control over plot styling to generate and export presentation-quality plots. Here's a demonstration of what it looks like in action:

Reading and Editing Maha Multics Files

MahaUtils includes utilities to make it easier to interact with Maha Multics input and output files. Rather than interacting with the raw content of the files, MahaUtils provides Python-based interfaces to edit file attributes. This avoids the need to understand and ensure that your files are correctly formatted -- MahaUtils performs error checks and formats the file behind-the-scenes before writing it.

For instance, here's an example of how to extract data from and edit a Maha Multics simulation results file:

from mahautils.multics import SimResults

# Read the file
sim_results = SimResults('simulation_results.txt')

# Print a list of variables in the file
print(sim_results.variables)

# Extract data from the file, with automatic unit conversions
position_meters = sim_results.get_data('xBlock', 'm')
position_inches = sim_results.get_data('xBlock', 'in')

# Edit data in the file
sim_results.set_description('xBlock', 'Position of the block')
sim_results.overwrite()

Similar tools are available for interacting with fluid property files, polygon files, and VTK files.

Generating Polygon Geometry

Maha Multics uses "polygon files" to specify geometry and apply boundary conditions in simulations. It can be tedious to create these files manually and ensure the correct format.

MahaUtils makes this process easier. It provides methods to create common geometric shapes and add them to polygon files, and then plot the file to ensure the geometry matches your expectations.

from mahautils.multics import PolygonFile
from mahautils.shapes import Circle, Layer

# Initialize the file
polygon_file = PolygonFile()

polygon_file.polygon_merge_method = 0
polygon_file.time_extrap_method = 0
polygon_file.time_units = 's'

# Add a translating circle
for i in range(25):
    polygon_file.polygon_data[i] = Layer(
        Circle(center=(i, 0), radius=4, units='mm',
               default_num_coordinates=1000),
        color='blue',
    )

# Preview the polygon file geometry
polygon_file.plot()

# Write to a file
polygon_file.write('my_polygon_file.txt')

Acknowledgments

Project source code is hosted on GitHub, releases are distributed through PyPI, and documentation is hosted through Read the Docs. Some README badges were generated using Shields.io.

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

mahautils-1.2.1.tar.gz (105.4 kB view details)

Uploaded Source

Built Distribution

mahautils-1.2.1-py3-none-any.whl (131.8 kB view details)

Uploaded Python 3

File details

Details for the file mahautils-1.2.1.tar.gz.

File metadata

  • Download URL: mahautils-1.2.1.tar.gz
  • Upload date:
  • Size: 105.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for mahautils-1.2.1.tar.gz
Algorithm Hash digest
SHA256 c10c6186551c815c3f94f26b906283fd74c83f234ec57db85c9b779bf1cfbf18
MD5 75e9110157cb72162751b8e300ccb940
BLAKE2b-256 b7864d1fe9688ce34e56be8ad675a6b08bac06e3f79d24f9f90c16000ebb3955

See more details on using hashes here.

File details

Details for the file mahautils-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: mahautils-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 131.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.13

File hashes

Hashes for mahautils-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 756d53e39416e22d249745366cc96c791f3b0965e57c986e05966734a75d571b
MD5 b430a8da2803ede0ef154d5fc2eae5aa
BLAKE2b-256 35034dfa97d093a6aa1ef7c231153c3c1d56d76333eaa8080d198018a2f6c148

See more details on using hashes here.

Supported by

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