diff --git a/.gitignore b/.gitignore index 72babfc..779ba37 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ venv/ *.mdb -motores/PLACond/ \ No newline at end of file +motores/PLACond/ +__pycache__/ \ No newline at end of file diff --git a/__pycache__/extraerH.cpython-313.pyc b/__pycache__/extraerH.cpython-313.pyc deleted file mode 100644 index 6f77403..0000000 Binary files a/__pycache__/extraerH.cpython-313.pyc and /dev/null differ diff --git a/__pycache__/genCurvas.cpython-313.pyc b/__pycache__/genCurvas.cpython-313.pyc deleted file mode 100644 index 53b0438..0000000 Binary files a/__pycache__/genCurvas.cpython-313.pyc and /dev/null differ diff --git a/__pycache__/motorcad.cpython-313.pyc b/__pycache__/motorcad.cpython-313.pyc deleted file mode 100644 index 7edade8..0000000 Binary files a/__pycache__/motorcad.cpython-313.pyc and /dev/null differ diff --git a/fluxcontrol.py b/fluxcontrol.py index 7555112..1be985e 100644 --- a/fluxcontrol.py +++ b/fluxcontrol.py @@ -13,7 +13,7 @@ if __name__ == '__main__': E_obj, I_obj, f_obj = gc.valores_objetivo(archivoEnsayos, material) - print(E_obj) + print("La tensión inducida objetivo son ", E_obj, " V") offset = 0 @@ -41,8 +41,8 @@ if __name__ == '__main__': error = np.mean(error) - print(tension) - print(error) + print("El resultado de la tensión inducida de la iteración ", i, " son ", tension, " V") + print("Y por tanto el error es igual a ", error) flag, offset = gc.logica_offset(offset, error, errorObjetivo) diff --git a/genCurvas.py b/genCurvas.py index f15b004..a6245bb 100644 --- a/genCurvas.py +++ b/genCurvas.py @@ -16,7 +16,7 @@ def generar_curva(offset, ruta): muVacio = 4 * np.pi * 1e-7 - with open("h_values.json", "r") as f : h = np.array(json.load(f)) + with open("h_values/h_values.json", "r") as f : h = np.array(json.load(f)) b = muVacio * h + offset with open(ruta, "w") as f: diff --git a/curva.txt b/h_values/curva.txt similarity index 100% rename from curva.txt rename to h_values/curva.txt diff --git a/extraerH.py b/h_values/extraerH.py similarity index 99% rename from extraerH.py rename to h_values/extraerH.py index f32861b..ec13303 100644 --- a/extraerH.py +++ b/h_values/extraerH.py @@ -2,7 +2,6 @@ import json h = [] - with open("curva.txt", "r") as f: for linea in f: if "HValue" in linea: diff --git a/h_values.json b/h_values/h_values.json similarity index 100% rename from h_values.json rename to h_values/h_values.json diff --git a/motorcad.py b/motorcad.py index d077ce7..679846d 100644 --- a/motorcad.py +++ b/motorcad.py @@ -1,15 +1,16 @@ import ansys.motorcad.core as MCAD import os -def simularMCAD(mdbName, iteration): +def simularMCAD(corriente, frecuencia, material, iteration): working_folder = os.getcwd() + motPath = os.path.join(working_folder, "motores", f"{material}.mot") + materialPath = os.path.join(working_folder, f"{material}.mdb") mcad = MCAD.MotorCAD() - motPath = os.path.join(working_folder, "motores", f"{mdbName}.mot") mcad.set_variable("MessageDisplayState", 2) mcad.set_visible(True) mcad.load_from_file(motPath) - print("Motor file loaded:", motPath) + print("Archivo de motor cargado desde:", motPath) # Simulation config mcad.set_variable("MagneticThermalCoupling", 0) @@ -25,14 +26,18 @@ def simularMCAD(mdbName, iteration): mcad.set_variable("TorqueCalculation", True) # Operation point - mcad.set_variable("ShaftSpeed", 1000) - mcad.set_variable("RMSCurrent", 0.95) - mcad.set_variable("DCBusVoltage", 400) + polos = mcad.get_variable("PoleNumber") + n = frecuencia * 60 / (polos/2) + mcad.set_variable("ShaftSpeed", n) + mcad.set_variable("RMSCurrent", corriente) + mcad.set_variable("DCBusVoltage", 230) mcad.set_variable("PhaseAdvance", 0) # Material - mcad.import_solid_material("C:\\Users\\promerogomb\\Desktop\\fluxcontrol\\PLACond.mdb", "PLACond") - mcad.set_component_material("Rotor Lam (Back Iron)", "PLACond") + mcad.import_solid_material(materialPath, material) + print("Material importado desde:", materialPath) + mcad.set_component_material("Rotor Lam (Back Iron)", material) + print("Material puesto en el rotor.") # Ejecución y resultados mcad.do_magnetic_calculation()