Toktom / PyAbsorp

PyAbsorp is a python module that has the main focus to help estimate the Sound Absorption Coefficient using analytical models.
MIT License
14 stars 3 forks source link

Improved API #3

Closed Chum4k3r closed 4 years ago

Chum4k3r commented 4 years ago

I've been watching your development for a while now and it is really impressive!

As my contribution to your wonderful package, I've developed two classes that may help on code modularization and reuse.

The AirProperties class is a simple interface to the air_properties function, that can have values reset and recalculate its own properties.

The Material class is an abstraction of a single material being studied, it holds physical information such as its thickness, porosity, tortuosity, etc, and also a reference to air properties and an array of frequencies to be modelled against.

The great trick here is the estimate_absorption method, which take a simple string with the absorption model name (e.g. "biot-allard" for Biot-Allard model), or even easier, only the model initials (e.g. "db" for Delany-Bazley model).

It also allows the use of model variations, such as the "allard" or "lafarge" versions of the Johnson-Champoux model by passing the corresponding string argument to the var parameter.

I've taken the care to document the most of it and work on two example codes that does the same job as the example_johnson_champoux.py code.

Feel free to question or to make any suggestions. Stay safe, wear mask and keep coding :D