Hi, I am using modulus 22.09 to train a model that provide flow field prediction for a 2D airfoil with changing angle of attack and inlet velocity.
I have trained the model and used the PointwiseMonitor to generate force coefficients outputs as the following codes:
aoa_list = [-10.,-5.,0.,5.,10.]
vel_eval = 1.0
for aoa_eval in aoa_list:
# generate force coefficient for each aoa_eval
inputs = geo.airfoil_geo.sample_boundary(
nr_points = 1000,
parameterization = {**{'aoa':aoa_eval},**{'vel_in':vel_eval}},
)
# PointwiseMonitor for each coefficients
force_coef = PointwiseMonitor(
inputs,
output_names=["u__x", "u__y", "v__x", "v__y","p"],
metrics={
"force_x_p_"+str(aoa_eval)+"_"+str(vel_eval): lambda var: torch.sum(-2.*var["normal_x"] * var["area"] * var["p"]),
"force_y_p_"+str(aoa_eval)+"_"+str(vel_eval): lambda var: torch.sum(-2.*var["normal_y"] * var["area"] * var["p"]),
"force_x_v_"+str(aoa_eval)+"_"+str(vel_eval): lambda var: torch.sum(2.*var["area"]*inv_Re*(2.*var["u__x"]*var["normal_x"] + var["u__y"]*var["normal_y"] + var["v__x"]*var["normal_y"])),
"force_y_v_"+str(aoa_eval)+"_"+str(vel_eval): lambda var: torch.sum(2.*var["area"]*inv_Re*(2.*var["v__y"]*var["normal_y"] + var["u__y"]*var["normal_x"] + var["v__x"]*var["normal_x"])),
},
nodes=flow_nodes,
)
domain.add_monitor(force_coef)
Then I run the code in eval mode and encountered the error:
Error executing job with overrides: []
Traceback (most recent call last):
File "naca0012_flow.py", line 385, in run
slv.solve()
File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/solver/solver.py", line 161, in solve
self._eval()
File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/trainer.py", line 784, in _eval
self._record_monitors(self.step)
File "/home/svu/e0444197/.local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/trainer.py", line 317, in _record_monitors
self.monitor_outvar = self.record_monitors(step)
File ".local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/solver/solver.py", line 148, in record_monitors
return self.domain.rec_monitors(self.network_dir, self.writer, step)
File ".local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/domain/domain.py", line 111, in rec_monitors
metrics.update(monitor.save_results(key, writer, step, monitor_data_dir))
File ".local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/domain/monitor/pointwise.py", line 60, in save_results
metrics = {key: func({**invar, **outvar}) for key, func in self.metrics.items()}
File ".local/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/domain/monitor/pointwise.py", line 60, in <dictcomp>
metrics = {key: func({**invar, **outvar}) for key, func in self.metrics.items()}
File "naca0012_flow.py", line 349, in <lambda>
"force_x_v_"+str(aoa_eval): lambda var: torch.sum(2.*var["area"]*inv_Re*(2.*var["u__x"]*var["normal_x"] + var["u__y"]*var["normal_y"] + var["v__x"]*var["normal_y"])),
TypeError: unsupported operand type(s) for *: 'Tensor' and 'Mul'
Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
The code works when I only add in the angle of attack as the variable, when I introduced in let velocity as the variable, the error occures. Can anybody help me with this?