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

Fix for Mach number; Y coordinate outputting #20

Merged
merged 3 commits into from
Jun 16, 2021
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
6 changes: 4 additions & 2 deletions src/api.f90
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ subroutine set_mach(M) bind(c, name='set_mach')

if (M /= MINf) then
MINf = M
MINf1 = M

call comset
if (MINf>0.0 .and. show_output) write (*, 99003) CPStar, QSTar / QINf
Expand Down Expand Up @@ -486,14 +487,14 @@ function get_n_cp() bind(c, name='get_n_cp')
get_n_cp = N
end function get_n_cp

subroutine get_cp(x_out, cp_out, n_points) bind(c, name='get_cp')
subroutine get_cp(x_out, y_out, cp_out, n_points) bind(c, name='get_cp')
use s_xfoil, only: comset
use m_xoper
use i_xfoil
implicit none

integer(c_int), intent(in) :: n_points
real(c_float), dimension(n_points), intent(inout) :: x_out, cp_out
real(c_float), dimension(n_points), intent(inout) :: x_out, y_out, cp_out

real :: beta, bfac, cpcom, cpinc, den
integer :: i
Expand All @@ -507,6 +508,7 @@ subroutine get_cp(x_out, cp_out, n_points) bind(c, name='get_cp')
den = beta + bfac * cpinc
cp_out(i) = cpinc / den
x_out(i) = X(i)
y_out(i) = Y(i)
enddo
end subroutine get_cp

Expand Down
7 changes: 5 additions & 2 deletions xfoil/xfoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,15 @@ def get_cp_distribution(self):
-------
x : np.array
X-coordinates
y : np.array
Y-coordinates
cp : np.ndarray
Pressure coefficients at the corresponding x-coordinates
"""
n = self._lib.get_n_cp()
x = np.zeros(n, dtype=c_float)
y = np.zeros(n, dtype=c_float)
cp = np.zeros(n, dtype=c_float)

self._lib.get_cp(x.ctypes.data_as(fptr), cp.ctypes.data_as(fptr), byref(c_int(n)))
return x.astype(float), cp.astype(float)
self._lib.get_cp(x.ctypes.data_as(fptr), y.ctypes.data_as(fptr), cp.ctypes.data_as(fptr), byref(c_int(n)))
return x.astype(float), y.astype(float), cp.astype(float)