diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59445f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +venv/ +curva.csv \ No newline at end of file diff --git a/automation.py b/automation.py deleted file mode 100644 index 565143d..0000000 --- a/automation.py +++ /dev/null @@ -1,11 +0,0 @@ -import numpy as np -import pandas as pd -import json -import h5py - -pyenv("Version", "3.9", "ExecutionMode","OutOfProcess") -pymotorcad = py.importlib.import_module('ansys.motorcad.core') - -pymotorcad.set_motorcad_exe('D:\Ansys_Motor-CAD\2024_2_2_1\Motor-CAD_2024_2_2_1.exe') - -mcApp=pymotorcad.MotorCAD() \ No newline at end of file diff --git a/genCurvas.py b/genCurvas.py index 7455d0e..a4f5034 100644 --- a/genCurvas.py +++ b/genCurvas.py @@ -30,7 +30,7 @@ if __name__ == '__main__': offset = 0 - flag = False + flag = True while flag: h,b = generar_curva(offset) diff --git a/motorcad.py b/motorcad.py new file mode 100644 index 0000000..f6aa035 --- /dev/null +++ b/motorcad.py @@ -0,0 +1,36 @@ +import ansys.motorcad.core as MCAD +import os + +mcad = MCAD.MotorCAD() + +if not mcad.is_alive(): + mcad.start() + +# --- 1. IMPORTAR MATERIAL PERSONALIZADO DESDE UNA CURVA --- + +material_curve_path = "PATH" +material_name = "PLACond" + +mcad.set_variable("ImportMaterialFile", material_curve_path) +mcad.set_variable("ImportMaterialName", material_name) +mcad.evaluate("ImportMaterial") + +print(f"Material '{material_name}' importado correctamente.") + +mcad.set_variable("RotorMaterial", material_name) + +# --- 2. CONFIGURAR Y CORRER SIMULACIÓN ELECTROMAGNÉTICA --- + +mcad.set_variable("SimulationType", "EMagnetic") + +mcad.set_variable("DriveSpeed", 1700) # rpm +mcad.set_variable("RatedCurrent", 2) # A + +mcad.evaluate("DoEmsolve") + +print("Simulación electromagnética completada.") + +torque_avg = mcad.get_variable("TorqueAvg") +print(f"Par promedio: {torque_avg:.2f} Nm") + +mcad.quit() \ No newline at end of file diff --git a/pymotorcad_cheat_sheet.png b/pymotorcad_cheat_sheet.png new file mode 100644 index 0000000..8ef950e Binary files /dev/null and b/pymotorcad_cheat_sheet.png differ diff --git a/requirements.py b/requirements.txt similarity index 53% rename from requirements.py rename to requirements.txt index 115055f..15875bb 100644 --- a/requirements.py +++ b/requirements.txt @@ -1,5 +1,4 @@ numpy pandas -json openpyxl -h5py==3.9 \ No newline at end of file +ansys.motorcad.core \ No newline at end of file