actualizacion con codigo

This commit is contained in:
Oscar Suescun Elizalde 2025-03-26 11:38:58 +01:00
parent cff7d8c356
commit a537276a78

View File

@ -2,6 +2,9 @@ import numpy as np
import pandas as pd import pandas as pd
import json import json
def valores_objetivo():
pass
def generar_curva(offset): def generar_curva(offset):
muVacio = 4 * np.pi * 1e-7 muVacio = 4 * np.pi * 1e-7
@ -14,17 +17,25 @@ def generar_curva(offset):
h = np.concatenate((hNeg, hPos)) h = np.concatenate((hNeg, hPos))
b = np.concatenate((bNeg, bPos)) b = np.concatenate((bNeg, bPos))
return h, b
datos = np.column_stack((h,b))
np.savetxt('curva.csv', datos, delimiter=',')
if __name__ == '__main__': 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']) carga = pd.read_excel(archivo, sheet_name='carga', engine='openpyxl').dropna()
Iobjetivo = np.array(datos['I'])
fObjetivo = np.array(datos['f']) 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 errorObjetivo = 0.01 # +- cuanto % puede haber de diferencia
errorCVobjetivo = 1
limSup = 1 + errorObjetivo limSup = 1 + errorObjetivo
limInf = errorObjetivo limInf = errorObjetivo
@ -32,13 +43,10 @@ if __name__ == '__main__':
flag = True flag = True
errorAnterior = 10000
while flag: while flag:
h,b = generar_curva(offset) generar_curva(offset)
datos = np.column_stack((h,b))
np.savetxt('curva.csv', datos, delimiter=',')
############################ ############################
''' '''
Logica de motorCAD-Pyhton, se sacaran unos vectores con Logica de motorCAD-Pyhton, se sacaran unos vectores con
@ -54,6 +62,11 @@ if __name__ == '__main__':
############################ ############################
error = Ecalc / Eobjetivo error = Ecalc / Eobjetivo
error = np.mean(Ecalc / Eobjetivo)
if error <= limSup and error >= limInf: flag = False
flag = False