def test1(self): twd = TowerWaveDrag() twd.U = [0., 8.80496275, 10.11424623, 10.96861453, 11.61821801, 12.14846828, 12.59962946, 12.99412772, 13.34582791, 13.66394248, 13.95492553, 14.22348635, 14.47317364, 14.70673252, 14.92633314, 15.13372281, 15.33033057, 15.51734112, 15.69574825, 15.86639432, 16.03] twd.z = [0., 4.38, 8.76, 13.14, 17.52, 21.9, 26.28, 30.66, 35.04, 39.42, 43.8, 48.18, 52.56, 56.94, 61.32, 65.7, 70.08, 74.46, 78.84, 83.22, 87.6] twd.d = [6., 5.8935, 5.787, 5.6805, 5.574, 5.4675, 5.361, 5.2545, 5.148, 5.0415, 4.935, 4.8285, 4.722, 4.6155, 4.509, 4.4025, 4.296, 4.1895, 4.083, 3.9765, 3.87] twd.beta = [0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.] twd.rho = 1.225 twd.mu = 1.7934e-05 twd.A = 1.1*twd.U twd.cm = 2.0 names, errors = check_gradient(twd) for name, err in zip(names, errors): if name == 'd_waveLoads.Px[0] / d_U[0]': tol = 2e-5 # central difference not accurate right at Re=0 else: tol = 1e-6 try: self.assertLessEqual(err, tol) except AssertionError, e: print '*** error in:', name raise e
def test1(self): soil = TowerSoil() soil.r0 = 10.0 soil.depth = 30.0 soil.G = 140e6 soil.nu = 0.4 soil.rigid = [False, False, False, False, False, False] names, errors = check_gradient(soil) tol = 1e-6 for name, err in zip(names, errors): try: self.assertLessEqual(err, tol) except AssertionError, e: print '*** error in:', name raise e
def test1(self): soil = TowerSoil() soil.r0 = 10.0 soil.depth = 30.0 soil.G = 140e6 soil.nu = 0.4 soil.rigid = [False, False, False, False, False, False] names, errors = check_gradient(soil) tol = 1e-6 for name, err in zip(names, errors): try: self.assertLessEqual(err, tol) except AssertionError, e: print "*** error in:", name raise e
def test1(self): twd = TowerWaveDrag() twd.U = [ 0., 8.80496275, 10.11424623, 10.96861453, 11.61821801, 12.14846828, 12.59962946, 12.99412772, 13.34582791, 13.66394248, 13.95492553, 14.22348635, 14.47317364, 14.70673252, 14.92633314, 15.13372281, 15.33033057, 15.51734112, 15.69574825, 15.86639432, 16.03 ] twd.z = [ 0., 4.38, 8.76, 13.14, 17.52, 21.9, 26.28, 30.66, 35.04, 39.42, 43.8, 48.18, 52.56, 56.94, 61.32, 65.7, 70.08, 74.46, 78.84, 83.22, 87.6 ] twd.d = [ 6., 5.8935, 5.787, 5.6805, 5.574, 5.4675, 5.361, 5.2545, 5.148, 5.0415, 4.935, 4.8285, 4.722, 4.6155, 4.509, 4.4025, 4.296, 4.1895, 4.083, 3.9765, 3.87 ] twd.beta = [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0. ] twd.rho = 1.225 twd.mu = 1.7934e-05 twd.A = 1.1 * twd.U twd.cm = 2.0 names, errors = check_gradient(twd) for name, err in zip(names, errors): if name == 'd_waveLoads.Px[0] / d_U[0]': tol = 2e-5 # central difference not accurate right at Re=0 else: tol = 1e-6 try: self.assertLessEqual(err, tol) except AssertionError, e: print '*** error in:', name raise e
def test1(self): lw = LogWind() lw.Uref = 12.0 lw.zref = 100.0 lw.z0 = 5.0 lw.z = np.linspace(4.9, 5.3, 20) lw.z_roughness = 10.0 lw.betaWind = 5.0 names, errors = check_gradient(lw) tol = 1e-6 for name, err in zip(names, errors): try: self.assertLessEqual(err, tol) except AssertionError, e: print "*** error in:", name raise e
def test3(self): pw = PowerWind() pw.Uref = 10.0 pw.zref = 100.0 pw.z0 = 0.0 pw.z = np.linspace(-10.0, 90.0, 20) pw.shearExp = 0.2 pw.betaWind = 5.0 names, errors = check_gradient(pw) tol = 1e-6 for name, err in zip(names, errors): try: self.assertLessEqual(err, tol) except AssertionError, e: print "*** error in:", name raise e
def test1(self): lw = LogWind() lw.Uref = 12.0 lw.zref = 100.0 lw.z0 = 5.0 lw.z = np.linspace(4.9, 5.3, 20) lw.z_roughness = 10.0 lw.betaWind = 5.0 names, errors = check_gradient(lw) tol = 1e-6 for name, err in zip(names, errors): try: self.assertLessEqual(err, tol) except AssertionError, e: print '*** error in:', name raise e
def test2(self): lw = LinearWaves() lw.Uc = 5.0 lw.z_surface = 20.0 lw.hs = 2.0 lw.T = 10.0 lw.z_floor = 0.0 lw.betaWave = 3.0 lw.z = np.linspace(-5.0, 50.0, 20) names, errors = check_gradient(lw) tol = 1e-6 for name, err in zip(names, errors): try: self.assertLessEqual(err, tol) except AssertionError, e: print "*** error in:", name raise e
def test3(self): pw = PowerWind() pw.Uref = 10.0 pw.zref = 100.0 pw.z0 = 0.0 pw.z = np.linspace(-10.0, 90.0, 20) pw.shearExp = 0.2 pw.betaWind = 5.0 names, errors = check_gradient(pw) tol = 1e-6 for name, err in zip(names, errors): try: self.assertLessEqual(err, tol) except AssertionError, e: print '*** error in:', name raise e
def test2(self): lw = LinearWaves() lw.Uc = 5.0 lw.z_surface = 20.0 lw.hs = 2.0 lw.T = 10.0 lw.z_floor = 0.0 lw.betaWave = 3.0 lw.z = np.linspace(-5.0, 50.0, 20) names, errors = check_gradient(lw) tol = 1e-6 for name, err in zip(names, errors): try: self.assertLessEqual(err, tol) except AssertionError, e: print '*** error in:', name raise e
def test1(self): pw = PowerWind() pw.Uref = 10.0 pw.zref = 100.0 pw.z0 = 0.0 pw.z = np.linspace(0.0, 100.0, 20) pw.shearExp = 0.2 pw.betaWind = 0.0 names, errors = check_gradient(pw) tol = 1e-6 for name, err in zip(names, errors): if name == "d_U[0] / d_z[0]": continue # the derivative at z==0 is a discontinuity. this node must not move in the optimization try: self.assertLessEqual(err, tol) except AssertionError, e: print "*** error in:", name raise e
def test1(self): pw = PowerWind() pw.Uref = 10.0 pw.zref = 100.0 pw.z0 = 0.0 pw.z = np.linspace(0.0, 100.0, 20) pw.shearExp = 0.2 pw.betaWind = 0.0 names, errors = check_gradient(pw) tol = 1e-6 for name, err in zip(names, errors): if name == 'd_U[0] / d_z[0]': continue # the derivative at z==0 is a discontinuity. this node must not move in the optimization try: self.assertLessEqual(err, tol) except AssertionError, e: print '*** error in:', name raise e
def test1(self): lw = LinearWaves() lw.Uc = 7.0 lw.z_surface = 20.0 lw.hs = 10.0 lw.T = 2.0 lw.z_floor = 0.0 lw.betaWave = 3.0 lw.z = np.linspace(0.0, 20.0, 20) names, errors = check_gradient(lw) tol = 1e-4 for name, err in zip(names, errors): if name in ("d_U[0] / d_z[0]", "d_U[19] / d_z[19]", "d_A[0] / d_z[0]", "d_A[19] / d_z[19]"): continue # the boundaries are not differentiable across bounds. these nodes must not move try: self.assertLessEqual(err, tol) except AssertionError, e: print "*** error in:", name raise e
def test1(self): lw = LinearWaves() lw.Uc = 7.0 lw.z_surface = 20.0 lw.hs = 10.0 lw.T = 2.0 lw.z_floor = 0.0 lw.betaWave = 3.0 lw.z = np.linspace(0.0, 20.0, 20) names, errors = check_gradient(lw) tol = 1e-4 for name, err in zip(names, errors): if name in ('d_U[0] / d_z[0]', 'd_U[19] / d_z[19]', 'd_A[0] / d_z[0]', 'd_A[19] / d_z[19]'): continue # the boundaries are not differentiable across bounds. these nodes must not move try: self.assertLessEqual(err, tol) except AssertionError, e: print '*** error in:', name raise e