# Add Lorentz force to CFD simulation

11 messages
Open this post in threaded view
|

## Add Lorentz force to CFD simulation

 Dear, i have a molten metal bath with cilindrical shape and induction heating, from electromagnetic simulation i know the Lorentz forces field. I would like to simulate the metal movement, is it possible to import the force field into the simulation? Sorry for my bad simulation of the question, i am new in CFD problems, thanks in advance for understanding. Marco
Open this post in threaded view
|

## Re: Add Lorentz force to CFD simulation

 Administrator Marco Passoni wrote i have a molten metal bath with cilindrical shape and induction heating, from electromagnetic simulation i know the Lorentz forces field. I would like to simulate the metal movement, is it possible to import the force field into the simulation? This sounds like a quite difficult simulation, and if you need to account for moving boundaries, possible melting and solidification then FEATool is not really a suitable software. That said, if you have measured data (such as your forces) you can create user defined coeffcient functions (Fx, Fy, Fz) where you would interpolate your data to the computational mesh used in the simulation. A 2D example is available in the documentation https://www.featool.com/doc/physics#phys_coef_user
Open this post in threaded view
|

## Re: Add Lorentz force to CFD simulation

 Dear, it looks wonderful, many thanks for the feedback. So, i have run the tutorial Axisymmetric Fluid flow, i changed the boundry condition of inlet/velocity into  wall/no slip and i get the fluid without movement, this was ok. After this, i try to put into Fr anf Fz fields constants or simple functions but there is no way to see movement of the fluid. I have misunderstood your suggestions? Do i have to edit equations? Thanks again for help. Best regards Marco
Open this post in threaded view
|

## Re: Add Lorentz force to CFD simulation

 Administrator This would be correct, however your coefficients might not be physically meaningful to generate flow via body forces (compared to other variables). The heat exchanger and natural convection tutorials show how to use the body/volume forces for a flow physics mode https://www.featool.com/doc/Multiphysics_00_heat_exchanger1https://www.featool.com/doc/Multiphysics_04_natural_convection1
Open this post in threaded view
|

## Re: Add Lorentz force to CFD simulation

 Many thanks for the reply. Thanks to the indicated tutorial i am now able to apply forces and see the resulting movement. Now i have to find the rigth way to import my force field into the model, i should be able to do by myself, 25 years ago i used Matlab during my PhD.... Best regards Marco
Open this post in threaded view
|

## Re: Add Lorentz force to CFD simulation

 In reply to this post by Precise Simulation Dear, i was able to use two m-functions to apply the forces along x and y direction. To explain better, functions are myfunFX(x,y) and myfunFY(x,y) for the forces in the two directions, i test in Matlab and works correctly. Anyway, based on the formula that i use i can have errors on FEATool simulation For example if i use return=1 or return =x or it works, if i use return = x^2 i get the error : Of course function on Matlab console works         Please give me a feedback on where i am wrong, many thanks. Marco
Open this post in threaded view
|

## Re: Add Lorentz force to CFD simulation

 Administrator You need to ensure that the output has the same expected array size as the input (in your case x and y). So here I guess you would need to use elementwise .dot notation, that is "x.^2" instead of "x^2" (which computes a matrix instead of vector). https://www.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html
Open this post in threaded view
|

## Re: Add Lorentz force to CFD simulation

 You are rigth, now it works, thanks for the help!!! So, my function must work with array and not with scalar, are x and y rows or column? In general my problem is that i can't check x and y variables on workspace. Is there a way to check FEATool variables on workspace? Best regards Marco
Open this post in threaded view
|

## Re: Add Lorentz force to CFD simulation

 Administrator Marco Passoni wrote So, my function must work with array and not with scalar, are x and y rows or column? In general my problem is that i can't check x and y variables on workspace. Is there a way to check FEATool variables on workspace? Variables you call custom functions "res = myfun(x,y,T,...)" are evaluated in the quadrature points in grid cells and are ordered as a column vector (note that myfun can be called several times in each solver step with different size inputs depending on how the evaluation is split over a number of cells). The result "res" is assumed to have the same size as the input. If you want to check in your function, you can put a breakpoint >> dbstop myfun https://www.mathworks.com/help/matlab/ref/dbstop.htmlthis will stop execution once your function is reached and you can proceed to inspect the variables (continue with dbcont/dbquit).