@@ -100,6 +100,65 @@ def test_porous_medium_simple_coefficients():
100100 assert np .isclose (CM [0 ] / CM [2 ], 2.0 , rtol = 1e-6 , atol = 1e-12 )
101101
102102
103+ def test_porous_medium_simple_coefficients_with_generic_reference_condition ():
104+ # Prepare a simple porous medium CSV with one timestep
105+ csv_path = os .path .join (
106+ os .path .dirname (__file__ ),
107+ os .path .pardir ,
108+ "data" ,
109+ "coeff_simple" ,
110+ "results" ,
111+ "porous_media_output_v2.csv" ,
112+ )
113+ csv_path = os .path .abspath (csv_path )
114+
115+ # Generic reference condition has no alpha/beta. In coefficient computations we assume:
116+ # lift direction = (0, 0, 1), drag direction = (1, 0, 0)
117+ with fl .SI_unit_system :
118+ params = fl .SimulationParams (
119+ reference_geometry = fl .ReferenceGeometry (
120+ moment_center = (0 , 0 , 0 ) * fl .u .m ,
121+ moment_length = 1 * fl .u .m ,
122+ area = 2.0 * fl .u .m ** 2 ,
123+ ),
124+ operating_condition = fl .GenericReferenceCondition (
125+ velocity_magnitude = 10 * fl .u .m / fl .u .s
126+ ),
127+ models = [
128+ fl .PorousMedium (
129+ entities = [
130+ fl .Box .from_principal_axes (
131+ name = "porous_zone" ,
132+ axes = [(1 , 0 , 0 ), (0 , 1 , 0 )],
133+ center = (0 , 0 , 0 ) * fl .u .m ,
134+ size = (0.2 , 0.3 , 2 ) * fl .u .m ,
135+ )
136+ ],
137+ darcy_coefficient = (1e6 , 0 , 0 ) / fl .u .m ** 2 ,
138+ forchheimer_coefficient = (1 , 0 , 0 ) / fl .u .m ,
139+ )
140+ ],
141+ private_attribute_asset_cache = AssetCache (project_length_unit = 1 * fl .u .m ),
142+ )
143+
144+ model = PorousMediumResultCSVModel ()
145+ model .load_from_local (csv_path )
146+ coeffs = model .compute_coefficients (params = params )
147+
148+ data = coeffs .as_dict ()
149+ CF = np .array (
150+ [data ["zone_0_CFx" ][0 ], data ["zone_0_CFy" ][0 ], data ["zone_0_CFz" ][0 ]], dtype = float
151+ )
152+
153+ # Drag/lift projections use default axes for GenericReferenceCondition
154+ drag_dir = np .array ([1.0 , 0.0 , 0.0 ], dtype = float )
155+ lift_dir = np .array ([0.0 , 0.0 , 1.0 ], dtype = float )
156+ CD = float (data ["zone_0_CD" ][0 ])
157+ CL = float (data ["zone_0_CL" ][0 ])
158+ assert np .isclose (CD , float (np .dot (CF , drag_dir )), rtol = 1e-6 , atol = 1e-12 )
159+ assert np .isclose (CL , float (np .dot (CF , lift_dir )), rtol = 1e-6 , atol = 1e-12 )
160+
161+
103162def test_porous_medium_real_case_coefficients ():
104163 """
105164 Test PorousMedium coefficient computation with real case data.
0 commit comments