This commit is contained in:
Pedro Romero 2025-03-26 11:07:54 +01:00
parent 384d6d5cfb
commit cff7d8c356
6 changed files with 40 additions and 14 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
venv/
curva.csv

View File

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

View File

@ -30,7 +30,7 @@ if __name__ == '__main__':
offset = 0
flag = False
flag = True
while flag:
h,b = generar_curva(offset)

36
motorcad.py Normal file
View File

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

BIN
pymotorcad_cheat_sheet.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 452 KiB

View File

@ -1,5 +1,4 @@
numpy
pandas
json
openpyxl
h5py==3.9
ansys.motorcad.core