thw1021 / Cylinder2DFlowControlGeneral

Robust active flow control over a range of Reynolds numbers using artificial neural network trained through deep reinforcement learning
MIT License
29 stars 14 forks source link

Negative drag values while training #7

Closed troy1729 closed 2 years ago

troy1729 commented 2 years ago

Hi,

I've recently started using RL to fluid problems. So please excuse for naive questions. While training the value of drag force is coming negative using fenics. Then how come Cd is graph is plotted with the positive value? Can you elaborate

Thanks

jerabaul29 commented 2 years ago

Duplicate of https://github.com/jerabaul29/Cylinder2DFlowControlDRL/issues/24 (please do not ask the same question twice at 2 different places). @thw1021 suggesting that you close here and we discuss on the repo upstreams :) .

thw1021 commented 2 years ago

OK, I try to explain. However, since this work was finished a long time ago and I do know much about FEniCS code, I am not sure that the answer is absolutely right.

The drag is calculated by https://github.com/thw1021/Cylinder2DFlowControlGeneral/blob/ac5ea7fd304dedefa4489790e45c42ca9428440e/RobustDRLCylinder2DControl/probes.py#L65-L66 and the facet normal vector n is obtained by https://github.com/thw1021/Cylinder2DFlowControlGeneral/blob/ac5ea7fd304dedefa4489790e45c42ca9428440e/RobustDRLCylinder2DControl/flow_solver.py#L54 and FacetNormal is defined here

Recall that when computing the lift and drag of the cylinder immersed in the fluid, we should use the normal vector that points outside of the boundary of the body. That's to say, n should multiply by -1 when computing the drag force and then the drag would be positive (of course, we did not do it here but when plotting the drag coefficients).

BTW, this "error" would not affect the results in our work since we used the absolute value of drag to compute the reward function.

Hope this answer helps.

jerabaul29 commented 2 years ago

Yes, this is the same that I explain at the link on the duplicate :) . I would not call it an "error", just a different convention (as we are well aware of it and tune the sign to have the effect we want depending on what we want to do :) ).

thw1021 commented 2 years ago

Just see that you have discussed on the repo 😂 so I close now.

jerabaul29 commented 2 years ago

No worries :) .