def set_type_mat(self, index): """Signal to update the material type according to the combobox Parameters ---------- self : A W_MatSetup object index : Current index of the combobox Returns ------- None """ if index == 0: # Raw Mat self.mat.mag = None self.nav_phy.removeTab(1) elif index == 1: # Magnet self.mat.mag = MatMagnet() self.mat.mag._set_None() self.nav_phy.insertTab(1, self.tab_mag, self.tr("Magnetics")) self.nav_mag.setCurrentIndex(0) else: # Lamination self.mat.mag = MatLamination() self.mat.mag._set_None() self.nav_phy.insertTab(1, self.tab_mag, self.tr("Magnetics")) self.nav_mag.setCurrentIndex(1)
def test_set_alpha_Br(self): """Check that the Widget allow to update alpha_Br""" # Set Material for Magnet self.test_obj.mag = MatMagnet() self.widget = DMatSetup(material=self.test_obj) self.widget.lf_alpha_Br.clear() # Clear the field before writing value = round(uniform(0, 1), 4) QTest.keyClicks(self.widget.lf_alpha_Br, str(value)) self.widget.lf_alpha_Br.editingFinished.emit() # To trigger the slot self.assertEqual(self.widget.mat.mag.alpha_Br, value)
def test_set_mur_lin(self): """Check that the Widget allow to update mur_lin""" self.widget.lf_mur_lin.clear() # Clear the field before writing value = round(uniform(0, 1), 4) QTest.keyClicks(self.widget.lf_mur_lin, str(value)) self.widget.lf_mur_lin.editingFinished.emit() # To trigger the slot self.assertEqual(self.widget.mat.mag.mur_lin, value) # Test also for Magnet Materials self.test_obj.mag = MatMagnet() self.widget = DMatSetup(material=self.test_obj) self.widget.lf_mur_lin.clear() # Clear the field before writing value = round(uniform(0, 1), 4) QTest.keyClicks(self.widget.lf_mur_lin, str(value)) self.widget.lf_mur_lin.editingFinished.emit() # To trigger the slot self.assertEqual(self.widget.mat.mag.mur_lin, value)
from pyleecan.Classes.Material import Material from pyleecan.Classes.MatMagnet import MatMagnet Magnet_prius = Material(name="Magnet_prius") Magnet_prius.mag = MatMagnet() Magnet_prius.elec.rho = 1.6e-06 Magnet_prius.mag.mur_lin = 1.05 Magnet_prius.mag.Hc = 902181.163126629 Magnet_prius.mag.alpha_Br = -0.001 Magnet_prius.mag.Brm20 = 1.24 Magnet_prius.struct.rho = 7500.0
def test_init(self): """Check that the Widget spinbox initialise to the lamination value""" self.assertEqual(self.widget.nav_ther.currentIndex(), 1) self.assertEqual(self.widget.nav_meca.currentIndex(), 1) self.assertEqual(self.widget.le_name.text(), "Magnet1") self.assertEqual(self.widget.is_isotropic.checkState(), Qt.Checked) self.assertEqual(self.widget.lf_rho_elec.value(), 0.11) self.assertEqual(self.widget.lf_mur_lin.value(), 0.12) self.assertEqual(self.widget.lf_Wlam.value(), 0.13) self.assertEqual(self.widget.lf_rho_meca.value(), 0.14) self.assertEqual(self.widget.lf_E.value(), 0.15) self.assertEqual(self.widget.lf_nu.value(), 0.16) self.assertEqual(self.widget.lf_G.value(), 0.17) self.assertEqual(self.widget.lf_L.value(), 0.18) self.assertEqual(self.widget.lf_Cp.value(), 0.19) self.assertEqual(self.widget.lf_alpha.value(), 0.2) self.assertEqual(self.widget.lf_cost_unit.value(), 0.21) self.assertEqual(self.widget.c_type_mat.currentIndex(), 2) # Test Raw Material self.test_obj.mag = None self.widget = DMatSetup(material=self.test_obj) self.assertEqual(self.widget.nav_ther.currentIndex(), 1) self.assertEqual(self.widget.nav_meca.currentIndex(), 1) self.assertEqual(self.widget.le_name.text(), "Magnet1") self.assertEqual(self.widget.is_isotropic.checkState(), Qt.Checked) self.assertEqual(self.widget.lf_rho_elec.value(), 0.11) self.assertEqual(self.widget.lf_rho_meca.value(), 0.14) self.assertEqual(self.widget.lf_E.value(), 0.15) self.assertEqual(self.widget.lf_nu.value(), 0.16) self.assertEqual(self.widget.lf_G.value(), 0.17) self.assertEqual(self.widget.lf_L.value(), 0.18) self.assertEqual(self.widget.lf_Cp.value(), 0.19) self.assertEqual(self.widget.lf_alpha.value(), 0.2) self.assertEqual(self.widget.lf_cost_unit.value(), 0.21) self.assertEqual(self.widget.c_type_mat.currentIndex(), 0) # Test Magnet material Non isotropic self.test_obj.is_isotropic = False self.test_obj.mag = MatMagnet(mur_lin=0.22, Brm20=0.23, alpha_Br=0.24) self.widget = DMatSetup(material=self.test_obj) self.assertEqual(self.widget.nav_ther.currentIndex(), 0) self.assertEqual(self.widget.nav_meca.currentIndex(), 0) self.assertEqual(self.widget.le_name.text(), "Magnet1") self.assertEqual(self.widget.is_isotropic.checkState(), Qt.Unchecked) self.assertEqual(self.widget.lf_rho_elec.value(), 0.11) self.assertEqual(self.widget.lf_mur_lin.value(), 0.22) self.assertEqual(self.widget.lf_Brm20.value(), 0.23) self.assertEqual(self.widget.lf_alpha_Br.value(), 0.24) self.assertEqual(self.widget.lf_rho_meca.value(), 0.14) self.assertEqual(self.widget.lf_Ex.value(), 0.15) self.assertEqual(self.widget.lf_Ey.value(), 0.152) self.assertEqual(self.widget.lf_Ez.value(), 0.153) self.assertEqual(self.widget.lf_nu_xy.value(), 0.16) self.assertEqual(self.widget.lf_nu_yz.value(), 0.162) self.assertEqual(self.widget.lf_nu_xz.value(), 0.163) self.assertEqual(self.widget.lf_Gxy.value(), 0.17) self.assertEqual(self.widget.lf_Gyz.value(), 0.172) self.assertEqual(self.widget.lf_Gxz.value(), 0.173) self.assertEqual(self.widget.lf_Lx.value(), 0.18) self.assertEqual(self.widget.lf_Ly.value(), 0.182) self.assertEqual(self.widget.lf_Lz.value(), 0.183) self.assertEqual(self.widget.lf_Cp.value(), 0.19) self.assertEqual(self.widget.lf_alpha.value(), 0.2) self.assertEqual(self.widget.lf_cost_unit.value(), 0.21) self.assertEqual(self.widget.c_type_mat.currentIndex(), 1)
from pyleecan.Classes.Material import Material from pyleecan.Classes.MatMagnet import MatMagnet Magnet1 = Material(name="Magnet1") Magnet1.mag = MatMagnet() Magnet1.elec.rho = 1.6e-06 Magnet1.mag.mur_lin = 1.05 Magnet1.mag.Hc = 757880.681389978 Magnet1.mag.alpha_Br = 0.0 Magnet1.mag.Brm20 = 1 Magnet1.struct.rho = 7500.0
from pyleecan.Classes.Material import Material from pyleecan.Classes.MatMagnet import MatMagnet Magnet3 = Material(name="Magnet3") Magnet3.mag = MatMagnet() Magnet3.elec.rho = 1.6e-06 Magnet3.mag.mur_lin = 1.05 Magnet3.mag.Hc = 909456.817667973 Magnet3.mag.alpha_Br = 0.0 Magnet3.mag.Brm20 = 1.2 Magnet3.struct.rho = 7500.0
from pyleecan.Classes.Material import Material from pyleecan.Classes.MatMagnet import MatMagnet Magnet5 = Material(name="Magnet5") Magnet5.mag = MatMagnet() Magnet5.elec.rho = 1.6e-06 Magnet5.mag.mur_lin = 1.05 Magnet5.mag.Hc = 917035.624481873 Magnet5.mag.alpha_Br = 0.0 Magnet5.mag.Brm20 = 1.21 Magnet5.struct.rho = 7500.0