From a537276a78cdf4d6ca2b5bf89b538043e76d50d9 Mon Sep 17 00:00:00 2001 From: Oscar Suescun Elizalde Date: Wed, 26 Mar 2025 11:38:58 +0100 Subject: [PATCH] actualizacion con codigo --- genCurvas.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/genCurvas.py b/genCurvas.py index a4f5034..8008356 100644 --- a/genCurvas.py +++ b/genCurvas.py @@ -2,6 +2,9 @@ import numpy as np import pandas as pd import json +def valores_objetivo(): + pass + def generar_curva(offset): muVacio = 4 * np.pi * 1e-7 @@ -14,17 +17,25 @@ def generar_curva(offset): h = np.concatenate((hNeg, hPos)) b = np.concatenate((bNeg, bPos)) - return h, b + + datos = np.column_stack((h,b)) + np.savetxt('curva.csv', datos, delimiter=',') if __name__ == '__main__': - with open('resultados_ensayos.json', 'r') as f: datos = json.load(f) + archivo = 'Ensayos.xlsx' + material = 'PLACOND' + masIter = 10000 - Eobjetivo = np.array(datos['E']) - Iobjetivo = np.array(datos['I']) - fObjetivo = np.array(datos['f']) + carga = pd.read_excel(archivo, sheet_name='carga', engine='openpyxl').dropna() + + Eobjetivo = np.mean(carga.loc[carga['material'] == material, ['V1', 'V2']].values, axis=1) + Iobjetivo = np.mean(carga.loc[carga['material'] == material, ['I1', 'I2']].values, axis=1) + fObjetivo = np.array(carga['f'][carga['material'] == material]) errorObjetivo = 0.01 # +- cuanto % puede haber de diferencia + errorCVobjetivo = 1 + limSup = 1 + errorObjetivo limInf = errorObjetivo @@ -32,13 +43,10 @@ if __name__ == '__main__': flag = True + errorAnterior = 10000 + while flag: - h,b = generar_curva(offset) - - datos = np.column_stack((h,b)) - - np.savetxt('curva.csv', datos, delimiter=',') - + generar_curva(offset) ############################ ''' Logica de motorCAD-Pyhton, se sacaran unos vectores con @@ -54,6 +62,11 @@ if __name__ == '__main__': ############################ error = Ecalc / Eobjetivo + error = np.mean(Ecalc / Eobjetivo) + + if error <= limSup and error >= limInf: flag = False + + flag = False