correccion 2

This commit is contained in:
Oscar Suescun Elizalde 2025-03-27 15:30:43 +01:00
parent c3c8c431a9
commit 889d36316f
4 changed files with 80 additions and 6 deletions

36
curva.txt Normal file
View File

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

17
extraerH.py Normal file
View File

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

View File

@ -1,6 +1,6 @@
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import random, os import random, os, json
def valores_objetivo(archivo, material): def valores_objetivo(archivo, material):
carga = pd.read_excel(archivo, sheet_name='carga', engine='openpyxl').dropna() 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): def generar_curva(offset, ruta):
muVacio = 4 * np.pi * 1e-7 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 b = muVacio * h + offset
with open(ruta, "w") as f: 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'BValue[0]=0\n')
f.write(f'HValue[0]=0\n') f.write(f'HValue[0]=0\n')
for i in np.arange(1,len(h)): for i in np.arange(len(h)):
f.write(f'BValue[{i}]={b[i]}\n') f.write(f'BValue[{i+1}]={b[i]}\n')
f.write(f'HValue[{i}]={h[i]}\n') f.write(f'HValue[{i+1}]={h[i]}\n')
@ -83,7 +84,7 @@ if __name__ == '__main__':
ruta = f'{directorio}{nombre}' ruta = f'{directorio}{nombre}'
offset = 0 offset = 0
generar_curva(1,ruta) generar_curva(offset,ruta)
# B = 1e-2 # B = 1e-2

20
h_values.json Normal file
View File

@ -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
]