Pyfluent solver 'velocity_inlet_child' object has no attribute 'turb_intensity' Attribute Error

CoolHarrison
CoolHarrison Member Posts: 13
First Comment
**
edited July 10 in Fluids

This code is from the Ahmed Body External Aerodynamics Simulation from Pyfluent's simulation examples, here's a link:https://examples.fluent.docs.pyansys.com/version/dev/examples/00-released_examples/00-ahmed_body_workflow.html#sphx-glr-examples-00-released-examples-00-ahmed-body-workflow-py

I've made 0 edits to the code, so I assume its just a version issue. Alas, here's where the error is, starting at line 245 in the "Boundary Conditions" section.
inlet = session.setup.boundary_conditions.velocity_inlet["inlet"] inlet.turb_intensity = 0.05 inlet.vmag = inlet_velocity inlet.turb_viscosity_ratio = 5

The first line of code works fine, but when the second line runs it gives me this:
Exception has occurred: AttributeError 'velocity_inlet_child' object has no attribute 'turb_intensity'. . The most similar names are: turbulence. File "C:\Users\User\OneDrive\Documents\GitHub\F1car-wAI\fluentTest.py", line 245, in <module> inlet.turb_intensity = 0.05 ^^^^^^^^^^^^^^^^^^^^ AttributeError: 'velocity_inlet_child' object has no attribute 'turb_intensity'. . The most similar names are: turbulence.

And when I change it to inlet.turbulence, I get:

Exception has occurred: RuntimeError CAR: invalid argument [1]: wrong type [not a pair]

I'm think its a version issue or something of the sort, because again I haven't changed anything about the code. I'm just not sure what version I should go to, or if it even is that problem entirely.

Best Answer

  • Gopi Raju Velpula
    Gopi Raju Velpula Member Posts: 18
    10 Comments First Answer Name Dropper Photogenic
    **
    Answer ✓

    Hi @CoolHarrison
    You can use below code. and also, I advise you to use PyFluent's most recent version (0.21).

    inlet = session.setup.boundary_conditions.velocity_inlet["inlet"]
    inlet.turbulence.turbulent_intensity = 0.05
    inlet.momentum.velocity.value = inlet_velocity
    inlet.turbulence.turbulent_viscosity_ratio_real = 5