Main fix and MCAD fix

This commit is contained in:
Pedro Romero 2025-03-31 11:31:56 +02:00
parent 7c14e88a2a
commit 0ac0e5c84d
10 changed files with 19 additions and 14 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
venv/
*.mdb
motores/PLACond/
motores/PLACond/
__pycache__/

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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:

View File

@ -2,7 +2,6 @@ import json
h = []
with open("curva.txt", "r") as f:
for linea in f:
if "HValue" in linea:

View File

@ -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()