Skip to content
Snippets Groups Projects
Commit eca70404 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

ignore fuga test if lib missing

parent b9e38bee
No related branches found
No related tags found
1 merge request!94Handle disabled mpi
......@@ -45,12 +45,14 @@ class Test(unittest.TestCase):
farms_dir=fuga_path + 'LUT/Farms/', wind_atlas_path='Horns Rev 1/hornsrev_north_only.lib', climate_interpolation=False)
def testCheckVersion(self):
if self.lib_missing(): return
lib = PascalDLL(fuga_path + "FugaLib/FugaLib.%s" % ('so', 'dll')[os.name == 'nt'])
self.assertRaisesRegex(Exception, "This version of FugaLib supports interface version ", lib.CheckInterfaceVersion, 1)
pyFuga = self.get_fuga() # check that current interface version match
pyFuga.cleanup()
def testSetup(self):
if self.lib_missing(): return
pyFuga = self.get_fuga()
self.assertEqual(pyFuga.get_no_tubines(), 2)
self.assertIn("Loading", pyFuga.log)
......@@ -61,11 +63,13 @@ class Test(unittest.TestCase):
pyFuga.cleanup()
def testAEP_one_tb(self):
if self.lib_missing(): return
pyFuga = self.get_fuga([0], [0])
np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0], [0]]).T), [7.44121, 7.44121, 0.424962, 1.])
pyFuga.cleanup()
def testAEP(self):
if self.lib_missing(): return
pyFuga = self.get_fuga()
np.testing.assert_array_almost_equal(pyFuga.get_aep(np.array([[0, 200], [0, 0]]).T), [14.848055, 14.882419, 0.423981, 0.997691])
......
......@@ -31,8 +31,12 @@ class PyFuga(object):
atexit.register(self.cleanup)
with NamedTemporaryFile() as f:
self.stdout_filename = f.name + "pyfuga.txt"
self.lib = PascalDLL(os.path.dirname(__file__) + "/Colonel/FugaLib/FugaLib.%s" % ('so', 'dll')[os.name == 'nt'])
lib_path = os.path.dirname(__file__) + "/Colonel/FugaLib/FugaLib.%s" % ('so', 'dll')[os.name == 'nt']
if os.path.isfile(lib_path):
raise Exception("Fuga lib cannot be found: '%s'" % lib_path)
self.lib = PascalDLL(lib_path)
self.lib.CheckInterfaceVersion(self.interface_version)
self.lib.Setup(self.stdout_filename, float(mast_position[0]), float(mast_position[1]), float(mast_position[2]),
float(z0), float(zi), float(zeta0))
......@@ -93,8 +97,8 @@ class PyFuga(object):
def get_aep(self, turbine_positions=None):
if turbine_positions is not None:
self.move_turbines(turbine_positions[:,0], turbine_positions[:,1])
self.move_turbines(turbine_positions[:, 0], turbine_positions[:, 1])
AEPNet_p = c_double_p(c_double(0))
AEPGros_p = c_double_p(c_double(0))
capacity_p = c_double_p(c_double(0))
......@@ -105,8 +109,8 @@ class PyFuga(object):
def get_aep_gradients(self, turbine_positions=None):
if turbine_positions is not None:
self.move_turbines(turbine_positions[:,0], turbine_positions[:,1])
self.move_turbines(turbine_positions[:, 0], turbine_positions[:, 1])
n_wt = self.get_no_tubines()
dAEPdxyz = np.zeros(n_wt), np.zeros(n_wt), np.zeros(n_wt)
dAEPdxyz_ctype = [dAEP.ctypes for dAEP in dAEPdxyz]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment