Skip to content

Commit 5942367

Browse files
Return the rms from XRotor.operate instead of boolean to quantify convergence.
1 parent d8a10f5 commit 5942367

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from setuptools.extension import Extension
2525
from setuptools.command.build_ext import build_ext
2626

27-
version = '0.0.7'
27+
version = '0.0.8'
2828

2929
options = {k: 'OFF' for k in ['--opt', '--debug', '--cuda']}
3030
for flag in options.keys():

src/fortran/interface.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ subroutine set_case(&
9696
end subroutine set_case
9797

9898
function operate(spec, val) bind(c, name='operate')
99-
logical(c_bool) :: operate
99+
real(c_float) :: operate
100100
integer(c_int), intent(in) :: spec
101101
real(c_float), intent(in) :: val
102102

@@ -110,11 +110,11 @@ function operate(spec, val) bind(c, name='operate')
110110
call aper(ctxt, 1, 2, ctxt%loprini)
111111
else
112112
print *, 'Unknown value for spec. Should be 1 to specify rpm, or 2 to specify thrust.'
113-
operate = .false.
113+
operate = 1.0
114114
return
115115
end if
116116

117-
operate = ctxt%conv
117+
operate = ctxt%rms
118118
end function operate
119119

120120
subroutine show() bind(c, name='show')

src/xrotor/test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ def test_solve_for_rpm(self):
9494
"""
9595
xr = XRotor()
9696
xr.case = Case.from_dict(case)
97-
conv = xr.operate(1, 2000)
97+
rms = xr.operate(1, 2000)
9898
perf = xr.performance
9999

100100
print_perf(perf)
101101

102-
self.assertTrue(conv)
102+
self.assertTrue(rms < 1.0e-7)
103103
self.assertAlmostEqual(perf.rpm, 2000, 0)
104104
self.assertAlmostEqual(perf.thrust, 481, 0)
105105
self.assertAlmostEqual(perf.torque, 105, 0)
@@ -117,12 +117,12 @@ def test_solve_for_thrust(self):
117117
"""
118118
xr = XRotor()
119119
xr.case = Case.from_dict(case)
120-
conv = xr.operate(2, 500)
120+
rms = xr.operate(2, 500)
121121
perf = xr.performance
122122

123123
print_perf(perf)
124124

125-
self.assertTrue(conv)
125+
self.assertTrue(rms < 1.0e-7)
126126
self.assertAlmostEqual(perf.rpm, 2019, 0)
127127
self.assertAlmostEqual(perf.thrust, 500, 0)
128128
self.assertAlmostEqual(perf.torque, 107, 0)

src/xrotor/xrotor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(self):
5050
self._lib = cdll.LoadLibrary(self._lib_path)
5151

5252
self._lib.get_print.restype = c_bool
53-
self._lib.operate.restype = c_bool
53+
self._lib.operate.restype = c_float
5454

5555
self._lib.init()
5656
self._case: Case = None
@@ -133,10 +133,10 @@ def operate(self, specify, value):
133133
134134
Returns
135135
-------
136-
conv : bool
137-
True is XRotor converged.
136+
rms : float
137+
Root-mean-squared error of XRotor's convergence. XRotor considers itself converged if rms < 1.0e-7.
138138
"""
139-
return self._lib.operate(byref(c_int(specify)), byref(c_float(value)))
139+
return float(self._lib.operate(byref(c_int(specify)), byref(c_float(value))))
140140

141141
def print_case(self):
142142
"""Print the characteristics of the run case at the last operating point to the terminal."""

0 commit comments

Comments
 (0)