Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'WaterNetworkModel' object has no attribute 'write_inpfile' #408

Closed
aljdmn opened this issue Mar 5, 2024 · 3 comments
Closed
Assignees
Labels

Comments

@aljdmn
Copy link

aljdmn commented Mar 5, 2024

Hi,

Im new developing wntr codes, and im starting from zero with a college project. I ve installed python 3.11 and wntr 1.1 and im using visual studio (i dont know if it´s relevant or not).

Keeping that in mind, i ve created this code below, apearing the next error:

AttributeError: 'WaterNetworkModel' object has no attribute 'write_inpfile'

Why my wntr version dont let me create inp files?

##################################
##################################
import wntr

wn = wntr.network.WaterNetworkModel()

#Parametres
n_ramales = 5 # Número de veces que quieres duplicar los ramales
longitud_tuberia = 2 # Longitud de las tuberías en metros
diametro_tuberia = 0.026 # Diámetro de las tuberías en metros
tipo_valvula = 'FCV' # Tipo de válvula, por ejemplo, una válvula reductora de presión ('PRV')

for i in range(n_ramales):
nodo_arriba = f"nodo_arriba_{i}"
nodo_abajo = f"nodo_abajo_{i}"
nodo_abajo2 = f"nodo_abajo_{i}"
nodo_arriba2 = f"nodo_arriba_{i}"
tuberia = f"tuberia_{i}"
valvula = f"valvula_{i}"

# Agrega nodos al modelo
wn.add_junction(nodo_arriba, base_demand=0, elevation=0.05)
wn.add_junction(nodo_abajo2, base_demand=0, elevation=0)
wn.add_junction(nodo_arriba2, base_demand=0, elevation=0.05)
wn.add_junction(nodo_abajo, base_demand=0, elevation=0)
# Agrega una válvula entre los nodos
wn.add_valve(valvula, nodo_arriba, nodo_abajo, diameter=0.015, valve_type=tipo_valvula)

# Agrega tubería conectando los nodos
wn.add_pipe(tuberia, nodo_arriba, nodo_arriba2, length=longitud_tuberia, diameter=diametro_tuberia)  # Tubería hasta la válvula
wn.add_pipe(f"{tuberia}_2", nodo_abajo, nodo_abajo2, length=longitud_tuberia, diameter=diametro_tuberia)  # Tubería después de la válvula

Guarda la red para visualización o análisis posterior

wn.write_inpfile("C:\Users\domen\Desktop\red_agua_con_valvulas.inp")

@ucchejbb
Copy link

ucchejbb commented Mar 5, 2024

write_inpfile has moved. It can now be called as wntr.network.io.write_inpfile( wntr_object, filename ). Hope that helps.

@aljdmn
Copy link
Author

aljdmn commented Mar 5, 2024

Yes, now it works thank you!!

I dont know if anything else has changed in earliest version, but for me would be usefull one list of the transformed codes (i only have the ones from the manual).

Anyway, thank you again.

@kaklise
Copy link
Collaborator

kaklise commented Apr 12, 2024

You can reference a list of changes in each release at https://usepa.github.io/WNTR/whatsnew.html.

@kaklise kaklise closed this as completed Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants