Error when applying k-e model to flow over airfoil problem

Hello, I am trying to apply k-e model to flow over 2D airfoil problem with Re = 1e5.
I have encountered a error when setting up the wall function constraint.
I generated a geometry that is a little bit thicker than the original airfoil, trying to make the y+ = 30. Then I use this as the geometry in the wall function constraint definition, as shown in the following:

wf_pt = PointwiseBoundaryConstraint(
            nodes=nodes_ke + nodes_u_tau,
            geometry=geo.airfoil1_geo,
            outvar={
                "velocity_wall_normal_wf": 0,
                "velocity_wall_parallel_wf": 0,
                "ep_wf": 0,
                "k_wf": 0,
                "wall_shear_stress_x_wf": 0,
                "wall_shear_stress_y_wf": 0,
            },
            lambda_weighting={
                "velocity_wall_normal_wf": 100,
                "velocity_wall_parallel_wf": 100,
                "ep_wf": 1,
                "k_wf": 1,
                "wall_shear_stress_x_wf": 100,
                "wall_shear_stress_y_wf": 100,
            },
            batch_size=cfg.batch_size.wf_1,
            parameterization={"normal_distance": resolved_y_start},
        )
        domain.add_constraint(wf_pt, "WF1")

Then I got the error report on this constraint, it is:

Error executing job with overrides: []
An error occurred during Hydra's exception formatting:
AssertionError()
Traceback (most recent call last):
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 252, in run_and_report
    assert mdl is not None
AssertionError


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "FX63-180_2_element_airfoil_varyAoA2_flow.py", line 672, in <module>
    run()
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/hydra/utils.py", line 91, in func_decorated
    _run_hydra(
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 377, in _run_hydra
    run_and_report(
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 294, in run_and_report
    raise ex
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 211, in run_and_report
    return func()
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/hydra/_internal/utils.py", line 378, in <lambda>
    lambda: hydra.run(
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 111, in run
    _ = ret.return_value
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/hydra/core/utils.py", line 233, in return_value
    raise self._return_value
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/hydra/core/utils.py", line 160, in run_job
    ret.return_value = task_function(task_cfg)
  File "FX63-180_2_element_airfoil_varyAoA2_flow.py", line 240, in run
    wf_pt = PointwiseBoundaryConstraint(
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/domain/constraint/continuous.py", line 276, in __init__
    invar = geometry.sample_boundary(
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/geometry/geometry.py", line 474, in sample_boundary
    [
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/geometry/geometry.py", line 475, in <listcomp>
    curve.approx_area(parameterization, criteria=closed_boundary_criteria)
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/geometry/curve.py", line 129, in approx_area
    s, p = self._sample(
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/geometry/curve.py", line 211, in sample
    invar, params = internal_sample(
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/geometry/curve.py", line 268, in sample
    computed_angle = angle(params)
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/geometry/helper.py", line 97, in func
    return fn_func(**inputs)
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/utils/sympy/numpy_printer.py", line 144, in grouped_lambda
    output.append(lambdify_f_i(**invar))
  File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/utils/sympy/numpy_printer.py", line 113, in lambdify_f_i
    v = np.stack(
  File "<__array_function__ internals>", line 180, in stack
  File "/usr/local/lib/python3.8/dist-packages/numpy/core/shape_base.py", line 422, in stack
    raise ValueError('need at least one array to stack')
ValueError: need at least one array to stack

I have tried changing the geometry I provided to this constraint but it didn’t work. Can anyone help me with this problem?

Thank you very much

Hi @TinsenLY

Its a little difficult to tell the exact problem here, but from I can tell its most likely because the geometry module is failing to sample the boundary of this geometry.

Perhaps you can try to isolate the boundary to verify and just call:

invar = geo.airfoil1_geo.sample_boundary(100)

And see if that works, if it does try adding the parameterization:

invar = geo.airfoil1_geo.sample_boundary(100, parameterization={"normal_distance": resolved_y_start})

If the first fails theres a problem with your geometry, if the second fails its the parameterization.

Hi @ngeneva ,

Thanks for your advice, I tried to comment the parameterization line and the code comes up with an fail unroll graph error. I checked the log and find that “normal_distance” is required for the nodes to calculate variables like “velocity_wall_parallel_wf”, “ep_wf”, “k_wf”, “wall_shear_stress_x_wf”, “wall_shear_stress_y_wf”.

Then I provided the paratmer “normal_distance” with the parameterization.

In my case, I don’t need the normal_distance to calculate the geometry for wall function, I read in airfoil points and use the polygon method to generate the airfoil geometry. I read in the airfoil boundary geometries that I to apply wall function directly. Yet I still import the normal_distance with the resolved_y_start value, which is a constant.

Could you please help me figure out how the parameterization result in an error shown above?

Hi @TinsenLY

So both of the code samples I gave work?

What is resolved_y_start here? Again its hard to debug this with the limited code snippet here. These numpy printer problems typically occur when some node/variable is not returning data. But its hard to say.

In my case, I don’t need the normal_distance to calculate the geometry for wall function

Yes this is correct. Its just that parameters are sampled with geometry which is why I wanted to verify the geometry was first functioning.