Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenVSP geometry import #40

Merged
merged 2 commits into from
Jun 10, 2024
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
44 changes: 44 additions & 0 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -1352,3 +1352,47 @@ nothing # hide
Visualizing the `k=0.5` case in ParaView yields the following animation.

![](heaving-rectangular-wing.gif)

## OpenVSP Geometry Import
This example shows how to import a wing geometry created using OpenVSP into VortexLattice for analysis. We'll make use of the default swept wing inside OpenVSP with a few minor changes.

![](samplewing.png)

Start up OpenVSP and create the default wing. Change the airfoil to NACA 2412 sections so that our wing has a camber to it. VortexLattice will make use of the cambersurface computed by OpenVSP when simulating it. The number of spanwise panels was increased to 20 per semispan in this example.

Once the geometry has been created, write out a DegenGeom file by selecting `DegenGeom` in the `Analysis` tab in OpenVSP. We only require a DegenGeom file in the csv format. The example DegenGeom file named `samplewing.csv` provided in `docs/src` was created in this manner.

The DegenGeom file can be imported into VortexLattice by using the functions [`read_degengeom`](@ref) and [`import_vsp`](@ref). The `read_degengeom` function reads the DegenGeom file into an array of components suitable for use inside Julia. The `import_vsp` function imports required components from the array as specified by the user.

In the following example code, a steady state analysis is performed on the sample wing imported from OpenVSP and results are visualized in Paraview.

```julia
using VortexLattice

Sref = 45.0
cref = 2.5
bref = 18.0
rref = [0.625, 0.0, 0.0]
Vinf = 1.0
ref = Reference(Sref, cref, bref, rref, Vinf)

alpha = 1.0*pi/180
beta = 0.0
Omega = [0.0; 0.0; 0.0]
fs = Freestream(Vinf, alpha, beta, Omega)

# Import components inside Degengeom file into Julia
comp = read_degengeom("samplewing.csv")

# Use the first (and only) imported component to create the lifting surface
grid, surface = import_vsp(comp[1]; mirror=true)

symmetric = false
surfaces = [surface]

system = steady_analysis(surfaces, ref, fs; symmetric=symmetric)
properties = get_surface_properties(system)
write_vtk("samplewing", surfaces, properties; symmetric)
```

![](samplewing-result.png)
Binary file added docs/src/samplewing-result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3,382 changes: 3,382 additions & 0 deletions docs/src/samplewing.csv

Large diffs are not rendered by default.

Binary file added docs/src/samplewing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,322 changes: 1,322 additions & 0 deletions docs/src/samplewing.vsp3

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1534,3 +1534,31 @@ end
# extract forces at each time step
CF, CM = body_forces_history(system, surface_history, property_history; frame=Wind())
end

@testset "OpenVSP Geometry Import" begin
Sref = 45.0
cref = 2.5
bref = 18.0
rref = [0.625, 0.0, 0.0]
Vinf = 1.0
ref = Reference(Sref, cref, bref, rref, Vinf)

alpha = 1.0*pi/180
beta = 0.0
Omega = [0.0; 0.0; 0.0]
fs = Freestream(Vinf, alpha, beta, Omega)

comp = read_degengeom("samplewing.csv")
grid, surface = import_vsp(comp[1]; mirror=true)

symmetric = false
surfaces = [surface]

system = steady_analysis(surfaces, ref, fs; symmetric=symmetric)
CF, CM = body_forces(system; frame=Wind())

CF_true = [2.41223539e-3, 0.0, 2.37009019e-1]
CM_true = [0.0, -2.75091871e-1, 0.0]
@test isapprox(CF, CF_true, atol=1e-5)
@test isapprox(CM, CM_true, atol=1e-5)
end
3,382 changes: 3,382 additions & 0 deletions test/samplewing.csv

Large diffs are not rendered by default.

Loading