def test_create_log_mean_profile(self): self.setup_test(domain_size=3) with patch('kratos_inlet_process.ImposeWindInletProcess.OpenFile') as file_: file_.return_value = self.mock_file process = kratos_inlet_process.ImposeWindInletProcess( self.model, self.settings) mean_profile = process.CreateLogMeanProfile() node = MagicMock(Z=20.) self.assertAlmostEqual(mean_profile.wind_speed(node), 12.3, places=2)
def test_update_inlet_position(self): self.setup_test(domain_size=3) with patch('kratos_inlet_process.ImposeWindInletProcess.OpenFile') as file_: file_.return_value = self.mock_file process = kratos_inlet_process.ImposeWindInletProcess( self.model, self.settings) process.mean_profile.bulk_wind_speed = 10.0 process.UpdateInletPosition() self.assertAlmostEqual(process.inlet_position, 1.0) for i in range(2): process.UpdateInletPosition() self.assertAlmostEqual(process.inlet_position, 1.0)
def test_create_2d_mappers(self): self.setup_test(domain_size=2) with patch('kratos_inlet_process.ImposeWindInletProcess.OpenFile') as file_: file_.return_value = self.mock_file process = kratos_inlet_process.ImposeWindInletProcess( self.model, self.settings) self.assertEqual(process.mappers[0][0], 'VELOCITY_X') self.assertEqual(process.mappers[1][0], 'VELOCITY_Z') mapper_u = process.mappers[0][1] mapper_u.update(process.inlet_position) self.assertAlmostEqual(mapper_u.interpolate(MagicMock(Z=0.5)), 0.05) mapper_u.update(0.5) self.assertAlmostEqual(mapper_u.interpolate(MagicMock(Z=0.5)), 0.075)
def test_init(self): self.setup_test(domain_size=3) with patch('kratos_inlet_process.ImposeWindInletProcess.OpenFile') as file_: file_.return_value = self.mock_file process = kratos_inlet_process.ImposeWindInletProcess( self.model, self.settings) self.assertEqual(process.inlet_model_part_name, 'inlet') self.assertEqual(process.wind_filename, 'wind.h5') self.assertAlmostEqual(process.inlet_position, 0.) self.assertAlmostEqual(process.ramp_time, 10.) self.assertAlmostEqual(process.lx, 2.) self.assertAlmostEqual(process.ly, 1.) self.assertAlmostEqual(process.lz, 1.) self.assertAlmostEqual(process.log_z0, 0.02) self.assertAlmostEqual(process.z, 20.) self.assertAlmostEqual(process.umean, 12.3) self.assertEqual(len(process.model_part.Nodes), 1)