peterdsharpe / AeroSandbox

Aircraft design optimization made fast through modern automatic differentiation. Composable analysis tools for aerodynamics, propulsion, structures, trajectory design, and much more.
https://peterdsharpe.github.io/AeroSandbox/
MIT License
687 stars 111 forks source link

Unable to Run Example Script #52

Closed KarlTaht closed 2 years ago

KarlTaht commented 3 years ago

Bug Description

Trying to run example script from the readme

Steps to Reproduce

Install package (either local or with pypi, tried both) Copy script from readme Run program

Expected Behavior

Produce images from readme, instead there is some incompatibility with WingXSec, these are easily fixed.

However, VLM3 is not found, and the existing example uses only airplane and op_point, while the current implementation also expects an "opti" param. I'm not sure how to incorporate this?

System Information

Other Information

Thanks! Would love to experiment with this program more, but need a basis to work off. I am trying to do some analysis for different car wing setups (single + dual element). Mostly interested in doing L/D analysis for various airfoil designs.

Anything to get me in the right direction would be appreciated! Thanks!

desarnez commented 3 years ago

Hello, I have the same issue here, have you been able to solve it ?

Christophe-Foyer commented 3 years ago

The readme seems to still be referring to code from AeroSandbox V2.

If you just want to run the readme code, simply install version 2.4.2 with its dependencies autograd and pyvista:

pip install AeroSandbox==2.4.2 autograd pyvista

Then you can just run it with legacy code as per Peter's suggestion for this issue. Simply replace from aerosandbox import * with from aerosandbox_legacy_v0 import *

The code should then run as-is.


For the v3 code:

I think the V3 code might need a few fixes before this works as expected though feel free to experiment. I quickly looked into it but it seems the wing sections also need to be slightly modified on top of the VortexLatticeMethod class in asb.aerodynamics to include some panelling info.

If you've already gotten past those issues, the opti that is required should simply be an AeroSandbox.Opti() instance unless it still uses the direct Casadi implementation in which case you just sub in a cas.Opti() instead.

I'll try and look into this if Peter or someone else hasn't done so already.

AerodynamicBrick commented 3 years ago

Version 2.3.5 works. hash 40b5c15, linked below.

Its only a few commits behind the legacy but the example code for the legacy runs on it. Imo this might be a better hash than the current legacy branch.

https://github.com/peterdsharpe/AeroSandbox/tree/40b5c15b6dddddcb8118585aea3eff09d632da5c

scivm commented 2 years ago

@AerodynamicBrick I tried the recommended hash using the README code from that hash and changing the initial import line to aerosandbox_legacy_v0.

The analysis ran but it could not draw.

Installing the hash:

pip3 install git+git://github.com/peterdsharpe/AeroSandbox.git@40b5c15b6dddddcb8118585aea3eff09d632da5c

Output from run:

mshamber@LR90TBHG2:~/git/plane/AeroSandbox.test$ python3 test2.pl
Running VLM3 calculation...
Meshing...
Meshing complete!
Calculating the collocation influence matrix...
Calculating the vortex center influence matrix...
Calculating the freestream influence...
Calculating vortex strengths...
Calculating forces on each panel...
Calculating total forces and moments...

Forces
-----
CL:  0.8404599690375737
CDi:  0.01634502408391746
CY:  -1.8730830318679936e-17
CL/CDi:  51.41992845789299

Moments
-----
Cl:  -1.9498170284985524e-18
Cm:  -0.15049347874120728
Cn:  1.9270374623587165e-18
VLM3 calculation complete!
Drawing...
Traceback (most recent call last):
  File "test2.pl", line 99, in <module>
    aero_problem.draw()  # Creates an interactive display of the surface pressures and streamlines
  File "/home/mshamber/.local/lib/python3.8/site-packages/aerosandbox_legacy_v0/aerodynamics/vlm3.py", line 734, in draw
    wing_surfaces = pv.PolyData(vertices, faces)
  File "/home/mshamber/.local/lib/python3.8/site-packages/pyvista/core/pointset.py", line 258, in __init__
    self.faces = CellArray(faces, n_faces, deep)
  File "/home/mshamber/.local/lib/python3.8/site-packages/pyvista/utilities/cells.py", line 86, in __init__
    self._set_cells(cells, n_cells, deep)
  File "/home/mshamber/.local/lib/python3.8/site-packages/pyvista/utilities/cells.py", line 89, in _set_cells
    vtk_idarr, cells = numpy_to_idarr(cells, deep=deep, return_ind=True)
  File "/home/mshamber/.local/lib/python3.8/site-packages/pyvista/utilities/cells.py", line 47, in numpy_to_idarr
    raise TypeError('Indices must be either a mask or an integer array-like')
TypeError: Indices must be either a mask or an integer array-like
scivm commented 2 years ago

It was an issue with how AeroSandbox is using pyvista. One of the arrays needs to be an integer array. See https://github.com/pyvista/pyvista/issues/810. The latest version of pyvista enforces this while previous versions did not.

If you use 0.24.3 of pyvista then you are able to pass this point. pip install pyvista==0.24.3

Since pyvista is deprecated in 3.x then it really doesn't matter?

scivm commented 2 years ago

If I understand correctly, from version 2 to 3, pyvista was replaced with plotly but the syntax for creating the airplane structures is similar.

peterdsharpe commented 2 years ago

Hi all,

Closing this issue, as this has been fixed. For syntax, see this tutorial.