Git Product home page Git Product logo

bladex's Introduction

Python Package for Blade Deformation

JOSS DOI Software License Build Status Coverage Status Codacy Badge

BladeX (Python Blade Morphing) is a Python package for geometrical parametrization and bottom-up construction of propeller blades. It allows to generate and deform a blade based on the radial distribution of its parameters.

Table of contents

Description

BladeX is a Python package for geometrical parametrization and bottom-up construction of propeller blades. It allows to generate and deform a blade based on the radial distribution of its parameters such as pitch, rake, skew, and the sectional foils' parameters such as chord and camber. The package is ideally suited for parametric simulations on large number of blade deformations. It provides an automated procedure for the CAD generation, hence reducing the time and effort required for modelling. The main scope of BladeX is to deal with propeller blades, however it can be flexible to be applied on further applications with analogous geometrical structures such as aircraft wings, turbomachinery, or wind turbine blades.

See the Examples section below and the Tutorials to have an idea of the potential of this package.

Dependencies and installation

BladeX requires numpy, scipy, matplotlib, sphinx (for the documentation), and pytest (for the local test). They can be easily installed using pip. BladeX is compatible with Python 3.6. Moreover, some of the modules require OCC to be installed for the .iges or .stl CAD generation. This requirement cannot be satisfied through pip, but the precompiled binaries are available on conda using the command:

> conda install -c conda-forge pythonocc-core=7.4.0

You can also refer to pythonocc.org or github.com/tpaviot/pythonocc-core for further instructions.

Installing from source

The official distribution is on GitHub, and you can clone the repository using

> git clone https://github.com/mathLab/BladeX

To install the latest version of the package just type:

> pip install git+https://github.com/mathLab/BladeX.git

Otherwise to install your own local branch you can use the setup.py file

> pip install -e .

To uninstall the package just use pip again:

> pip uninstall bladex

Documentation

BladeX uses Sphinx for code documentation. You can view the documentation online here. To build the html version of the docs locally simply:

> cd docs
> make html

The generated html can be found in docs/build/html. Open up the index.html you find there to browse.

Testing

We are using Github Actions for continuous intergration testing. You can check out the current status here.

To run tests locally:

> pytest

Examples

You can find useful tutorials on how to use the package in the tutorials folder. Here we show a bottom-up parametrized construction of the Potsdam Propeller Test Case (PPTC) provided the sectional profiles as well as the radial distribution of the pitch, rake, skew. The blade is generated and exported to .iges and .stl formats.

PPTC blade generation according to the radial distribution of the pitch, rake, skew. The generated blade is then exported to .iges and .stl formats.

Two possible deformed geometry configurations, to show the capabilities of the package, are presented here:

Undeformed reference blade on the left, and a couple of deformed configurations obtained by moving some control points defining the skew and chord length radial distributions.

How to cite

If you use this package in your publications please cite the package as follows:

Gadalla et al., (2019). BladeX: Python Blade Morphing. Journal of Open Source Software, 4(34), 1203, https://doi.org/10.21105/joss.01203

Or if you use LaTeX:

@article{gadalla19bladex,
  Author = {Gadalla, Mahmoud and Tezzele, Marco and Mola, Andrea and Rozza, Gianluigi},
  Title = {{BladeX: Python Blade Morphing}},
  Journal = {The Journal of Open Source Software},
  Volume = {4},
  Number = {34},
  Pages = {1203},
  Year = {2019},
  Doi = {https://doi.org/10.21105/joss.01203}
}

Recent works with BladeX

Here there is a list of the scientific works involving BladeX you can consult and/or cite. If you want to add one, please open a PR.

  • Mola, Tezzele, Gadalla, Valdenazzi, Grassi, Padovan, Rozza. Efficient reduction in shape parameter space dimension for ship propeller blade design. In Proceedings of MARINE 2019: VIII International Conference on Computational Methods in Marine Engineering, pages 201โ€“212, 2019. [DOI] [arXiv] [bibitem].

  • Tezzele, Demo, Mola, Rozza. An integrated data-driven computational pipeline with model order reduction for industrial and applied mathematics. Submitted, 2018. [arXiv] [bibitem].

Authors and contributors

BladeX is currently developed and mantained at SISSA mathLab by

under the supervision of Dr. Andrea Mola and Prof. Gianluigi Rozza in the framework of the project PRELICA: Advanced Methodologies for Hydro-acoustic Design of Naval Propulsion.

Support

Contact us by email for further information or questions about BladeX. Feel free to suggest pull requests or to open GitHub issues. Contributions improving either the code or the documentation are welcome!

How to contribute

We'd love to accept your patches and contributions to this project. There are just a few small guidelines you need to follow.

Submitting a patch

  1. It's generally best to start by opening a new issue describing the bug or feature you're intending to fix. Even if you think it's relatively minor, it's helpful to know what people are working on. Mention in the initial issue that you are planning to work on that bug or feature so that it can be assigned to you.

  2. Follow the normal process of forking the project, and setup a new branch to work in. It's important that each group of changes be done in separate branches in order to ensure that a pull request only includes the commits related to that bug or feature.

  3. To ensure properly formatted code, please make sure to use 4 spaces to indent the code. The easy way is to run on your bash the provided script: ./code_formatter.sh. You should also run pylint over your code. It's not strictly necessary that your code be completely "lint-free", but this will help you find common style issues.

  4. Any significant changes should almost always be accompanied by tests. The project already has good test coverage, so look at some of the existing tests if you're unsure how to go about it. We're using coveralls that is an invaluable tools for seeing which parts of your code aren't being exercised by your tests.

  5. Do your best to have well-formed commit messages for each change. This provides consistency throughout the project, and ensures that commit messages are able to be formatted properly by various git tools.

  6. Finally, push the commits to your fork and submit a pull request. Please, remember to rebase properly in order to maintain a clean, linear git history.

SISSA mathLab packages for reduced order modeling

Below you can find a list of useful reduced order modelling packages from SISSA mathLab group:

  • PyGeM: Python library for Geometrical Morphing, that uses free form deformation to parametrize and morph complex geometries, https://github.com/mathLab/PyGeM.
  • PyDMD: Python library for Dynamic Mode Decomposition, for a data-driven model simplification based on spatiotemporal coherent structures, https://github.com/mathLab/PyDMD.
  • RBniCS: reduced order modelling in FEniCS, is an implementation in FEniCS of several reduced order modelling techniques for parametrized problems, https://github.com/mathLab/RBniCS.
  • EZyRB: Easy Reduced Basis method, is a python library for the Model Order Reduction based on baricentric triangulation for the selection of the parameter points and on Proper Orthogonal Decomposition for the selection of the modes, https://github.com/mathLab/EZyRB.
  • ITHACA-FV: In real Time Highly Advanced Computational Applications for Finite Volumes, is C++ library based on the finite volume solver OpenFOAM. It consists of the implementation of several reduced order modeling techniques for parametrized problems, https://github.com/mathLab/ITHACA-FV.
  • ITHACA-DG: In real Time Highly Advanced Computational Applications for Discontinuous Galerkin Methods, is C++ library based on the Discontinuous Galerkin Methods solver HopeFOAM. It consists of the implementation of reduced order modeling techniques for parametrized problems, https://github.com/mathLab/ITHACA-DG.
  • ITHACA-SEM: In real Time Highly Advanced Computational Applications for Spectral Element Methods, is C++ library based on the spectral element solver Nektar++. It consists of the implementation of several reduced order modeling techniques for parametrized problems, https://github.com/mathLab/ITHACA-SEM.

License

See the LICENSE file for license rights and limitations (MIT).

bladex's People

Contributors

annaivagnes avatar fandreuz avatar ggurioli avatar mahgadalla avatar mtezzele avatar ndem0 avatar twisterbboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bladex's Issues

error on `Propeller.generate_obj` (due to `OCC.Extend.DataExchange.write_stl_file`)

Describe the bug
A bug occurs using the Windows OS in the function write_stl_file from the pythonocc library. At the moment no issues related with this bug are opened in the Github page of pythonocc-core library. Additionally, the same method write_stl_file is also used in Propeller.generate_stl with no errors in this case.

To Reproduce
pytest tests/test_propeller

Output

================================== FAILURES ===================================
_______________ TestPropeller.test_generate_obj_blades_and_stem _______________

self = <tests.test_propeller.TestPropeller testMethod=test_generate_obj_blades_and_stem>

    def test_generate_obj_blades_and_stem(self):
        sh = Shaft("tests/test_datasets/shaft.iges")
        prop = create_sample_blade_NACApptc()
        prop = Propeller(sh, prop, 4)
>       prop.generate_obj("tests/test_datasets/propeller_and_shaft.obj", region_selector='blades_and_stem')

tests\test_propeller.py:192: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
bladex\propeller.py:105: in generate_obj
    write_stl_file(self.shaft_solid, "/tmp/temp_shaft.stl")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a_shape = <class 'TopoDS_Solid'>, filename = '/tmp/temp_shaft.stl'
mode = 'ascii', linear_deflection = 0.9, angular_deflection = 0.5

    def write_stl_file(a_shape, filename, mode="ascii", linear_deflection=0.9, angular_deflection=0.5):
        """ export the shape to a STL file
        Be careful, the shape first need to be explicitely meshed using BRepMesh_IncrementalMesh
        a_shape: the topods_shape to export
        filename: the filename
        mode: optional, "ascii" by default. Can either be "binary"
        linear_deflection: optional, default to 0.001. Lower, more occurate mesh
        angular_deflection: optional, default to 0.5. Lower, more accurate_mesh
        """
        if a_shape.IsNull():
            raise AssertionError("Shape is null.")
        if mode not in ["ascii", "binary"]:
            raise AssertionError("mode should be either ascii or binary")
        if os.path.isfile(filename):
            print("Warning: %s file already exists and will be replaced" % filename)
        # first mesh the shape
        mesh = BRepMesh_IncrementalMesh(a_shape, linear_deflection, False, angular_deflection, True)
        #mesh.SetDeflection(0.05)
        mesh.Perform()
        if not mesh.IsDone():
            raise AssertionError("Mesh is not done.")
    
        stl_exporter = StlAPI_Writer()
        if mode == "ascii":
            stl_exporter.SetASCIIMode(True)
        else:  # binary, just set the ASCII flag to False
            stl_exporter.SetASCIIMode(False)
        stl_exporter.Write(a_shape, filename)
    
        if not os.path.isfile(filename):
>           raise IOError("File not written to disk.")
E           OSError: File not written to disk.

C:\Miniconda\envs\__setup_conda\lib\site-packages\OCC\Extend\DataExchange.py:353: OSError
__________________ TestPropeller.test_generate_obj_by_coords __________________

self = <tests.test_propeller.TestPropeller testMethod=test_generate_obj_by_coords>

    def test_generate_obj_by_coords(self):
        sh = Shaft("tests/test_datasets/shaft.iges")
        prop = create_sample_blade_NACApptc()
        prop = Propeller(sh, prop, 4)
>       prop.generate_obj("tests/test_datasets/propeller_and_shaft.obj", region_selector='by_coords')

tests\test_propeller.py:163: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
bladex\propeller.py:[105](https://github.com/mathLab/BladeX/actions/runs/3046074863/jobs/4908427376#step:7:106): in generate_obj
    write_stl_file(self.shaft_solid, "/tmp/temp_shaft.stl")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a_shape = <class 'TopoDS_Solid'>, filename = '/tmp/temp_shaft.stl'
mode = 'ascii', linear_deflection = 0.9, angular_deflection = 0.5

    def write_stl_file(a_shape, filename, mode="ascii", linear_deflection=0.9, angular_deflection=0.5):
        """ export the shape to a STL file
        Be careful, the shape first need to be explicitely meshed using BRepMesh_IncrementalMesh
        a_shape: the topods_shape to export
        filename: the filename
        mode: optional, "ascii" by default. Can either be "binary"
        linear_deflection: optional, default to 0.001. Lower, more occurate mesh
        angular_deflection: optional, default to 0.5. Lower, more accurate_mesh
        """
        if a_shape.IsNull():
            raise AssertionError("Shape is null.")
        if mode not in ["ascii", "binary"]:
            raise AssertionError("mode should be either ascii or binary")
        if os.path.isfile(filename):
            print("Warning: %s file already exists and will be replaced" % filename)
        # first mesh the shape
        mesh = BRepMesh_IncrementalMesh(a_shape, linear_deflection, False, angular_deflection, True)
        #mesh.SetDeflection(0.05)
        mesh.Perform()
        if not mesh.IsDone():
            raise AssertionError("Mesh is not done.")
    
        stl_exporter = StlAPI_Writer()
        if mode == "ascii":
            stl_exporter.SetASCIIMode(True)
        else:  # binary, just set the ASCII flag to False
            stl_exporter.SetASCIIMode(False)
        stl_exporter.Write(a_shape, filename)
    
        if not os.path.isfile(filename):
>           raise IOError("File not written to disk.")
E           OSError: File not written to disk.

C:\Miniconda\envs\__setup_conda\lib\site-packages\OCC\Extend\DataExchange.py:353: OSError

Additional context
No errors using MacOS or Linux.

Python 3.8 and higher supported

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

python 3.6 not in Security support
https://devguide.python.org/versions/

Describe the solution you'd like
A clear and concise description of what you want to happen.

Update to python 3.8 or higher

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Documentation outdated

It looks like the documentation has not been updated to match the last modifications. The docstrings are updated:

BladeX/bladex/blade.py

Lines 930 to 972 in 905eb8f

def generate_stl(self, upper_face=None,
lower_face=None,
tip=None,
root=None,
max_deg=1,
display=False,
errors=None):
"""
Generate and export the .STL files for upper face, lower face, tip
and root. This method requires PythonOCC (7.4.0) to be installed.
:param string upper_face: if string is passed then the method generates
the blade upper surface using the BRepOffsetAPI_ThruSections
algorithm, then exports the generated CAD into .stl file holding
the name <upper_face_string>.stl. Default value is None
:param string lower_face: if string is passed then the method generates
the blade lower surface using the BRepOffsetAPI_ThruSections
algorithm, then exports the generated CAD into .stl file holding
the name <lower_face_string>.stl. Default value is None
:param string tip: if string is passed then the method generates
the blade tip using the BRepOffsetAPI_ThruSections algorithm
in order to close the blade at the tip, then exports the generated
CAD into .stl file holding the name <tip_string>.stl.
Default value is None
:param string root: if string is passed then the method generates
the blade root using the BRepOffsetAPI_ThruSections algorithm
in order to close the blade at the root, then exports the generated
CAD into .stl file holding the name <tip_string>.stl.
Default value is None
:param int max_deg: Define the maximal U degree of generated surface.
Default value is 1
:param bool display: if True, then display the generated CAD. Default
value is False
:param string errors: if string is passed then the method writes out
the distances between each discrete point used to construct the
blade and the nearest point on the CAD that is perpendicular to
that point. Default value is None
We note that the blade object must have its radial sections be arranged
in order from the blade root to the blade tip, so that generate_stl
method can build the CAD surface that passes through the corresponding
airfoils. Also to be able to identify and close the blade tip and root.
"""

but the generated HTML file aren't (https://mathlab.github.io/BladeX/_summaries/bladex.blade.Blade.generate_stl.html).

Fix tests dataset

Files in tests/test_dataset automatically removed when running tests.

More export by occ possible with step, GLTF and obj

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

actual python-occ-core can export more formats with step, obj and GLTF
https://github.com/tpaviot/pythonocc-core
Actual version is 7.8.1, here in use 7.4.0

Describe the solution you'd like
A clear and concise description of what you want to happen.

update to higher version than here used 7.4.0, actual is 7.8.1 and extend export to more formats.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Update README

Dependencies/installation part has to be updated for python-occ 7.4.0

Suggestion: clarify support channels

In the "Authors and contributors" section of the README, users are encouraged to contact @mahgadalla and @mtezzele by email. Although it's crystal clear, I would suggest to include a explicit "Support" section in the README stating that, and also clarifying whether GitHub issues are welcomed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.