From 889d36316f1eb6043b3451a6594ef50fa1a1d643 Mon Sep 17 00:00:00 2001 From: Oscar Suescun Elizalde Date: Thu, 27 Mar 2025 15:30:43 +0100 Subject: [PATCH] correccion 2 --- curva.txt | 36 ++++++++++++++++++++++++++++++++++++ extraerH.py | 17 +++++++++++++++++ genCurvas.py | 13 +++++++------ h_values.json | 20 ++++++++++++++++++++ 4 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 curva.txt create mode 100644 extraerH.py create mode 100644 h_values.json diff --git a/curva.txt b/curva.txt new file mode 100644 index 0000000..44d7272 --- /dev/null +++ b/curva.txt @@ -0,0 +1,36 @@ +BValue[1]=0.2 +HValue[1]=31.9 +BValue[2]=0.4 +HValue[2]=44.9 +BValue[3]=0.7 +HValue[3]=67.3 +BValue[4]=1 +HValue[4]=106 +BValue[5]=1.2 +HValue[5]=164 +BValue[6]=1.3 +HValue[6]=235 +BValue[7]=1.4 +HValue[7]=435 +BValue[8]=1.5 +HValue[8]=1109 +BValue[9]=1.55 +HValue[9]=1813 +BValue[10]=1.6 +HValue[10]=2802 +BValue[11]=1.65 +HValue[11]=4054 +BValue[12]=1.7 +HValue[12]=5592 +BValue[13]=1.8 +HValue[13]=9711 +BValue[14]=1.9 +HValue[14]=18500 +BValue[15]=2 +HValue[15]=45000 +BValue[16]=2.1 +HValue[16]=88491 +BValue[17]=2.2 +HValue[17]=140000 +BValue[18]=2.3 +HValue[18]=200000 \ No newline at end of file diff --git a/extraerH.py b/extraerH.py new file mode 100644 index 0000000..f32861b --- /dev/null +++ b/extraerH.py @@ -0,0 +1,17 @@ +import json + +h = [] + + +with open("curva.txt", "r") as f: + for linea in f: + if "HValue" in linea: + partes = linea.strip().split("=") + h_val = float(partes[1]) + h.append(h_val) + + +print(h) + +with open("h_values.json", "w") as json_file: + json.dump(h, json_file, indent=4) \ No newline at end of file diff --git a/genCurvas.py b/genCurvas.py index ac71d17..b78b720 100644 --- a/genCurvas.py +++ b/genCurvas.py @@ -1,6 +1,6 @@ import numpy as np import pandas as pd -import random, os +import random, os, json def valores_objetivo(archivo, material): carga = pd.read_excel(archivo, sheet_name='carga', engine='openpyxl').dropna() @@ -15,7 +15,8 @@ def valores_objetivo(archivo, material): def generar_curva(offset, ruta): muVacio = 4 * np.pi * 1e-7 - h = np.arange(1,30000,1000) + + with open("h_values.json", "r") as f : h = np.array(json.load(f)) b = muVacio * h + offset with open(ruta, "w") as f: @@ -34,9 +35,9 @@ def generar_curva(offset, ruta): f.write(f'BValue[0]=0\n') f.write(f'HValue[0]=0\n') - for i in np.arange(1,len(h)): - f.write(f'BValue[{i}]={b[i]}\n') - f.write(f'HValue[{i}]={h[i]}\n') + for i in np.arange(len(h)): + f.write(f'BValue[{i+1}]={b[i]}\n') + f.write(f'HValue[{i+1}]={h[i]}\n') @@ -83,7 +84,7 @@ if __name__ == '__main__': ruta = f'{directorio}{nombre}' offset = 0 - generar_curva(1,ruta) + generar_curva(offset,ruta) # B = 1e-2 diff --git a/h_values.json b/h_values.json new file mode 100644 index 0000000..8bb4843 --- /dev/null +++ b/h_values.json @@ -0,0 +1,20 @@ +[ + 31.9, + 44.9, + 67.3, + 106.0, + 164.0, + 235.0, + 435.0, + 1109.0, + 1813.0, + 2802.0, + 4054.0, + 5592.0, + 9711.0, + 18500.0, + 45000.0, + 88491.0, + 140000.0, + 200000.0 +] \ No newline at end of file