Heat source for microwave heating

Numerical methods and mathematical models of Elmer
elelel
Posts: 32
Joined: 23 May 2022, 17:37
Antispam: Yes

Re: Heat source for microwave heating

Post by elelel »

Hi
I want the heat source to vary depending on the temperature of a specified node.The result looks like the heat source at each node changes at its own temperature, but not at the temperature of the specified node.In other words, the heat source of each node is changing its own, and I can't control the overall heat source.I don't know if I have made it clear.

Code: Select all

FUNCTION heatsource(Model, n, dummyArgument) RESULT(ht)
  USE DefUtils
  USE VectorHelmholtzUtils
  IMPLICIT None
  TYPE(Model_t) :: Model
  INTEGER :: n
  REAL(KIND=dp) :: dummyArgument, dt

  TYPE(Variable_t), POINTER :: Poyvar
  REAL(KIND=dp) :: hvar,ht,Poy,tlimit,hcon,mindist,x0,y0,z0,dist,jx,jy,jz,Temp
  INTEGER :: HeatControlNode,l
  REAL(KIND=dp), ALLOCATABLE :: localTemp(:)
  
!get HeatControlNode and its Temperature
  ALLOCATE(localTemp(CurrentModel % MaxElementNodes))
  CALL GetScalarLocalSolution(localTemp, 'Temperature')
  x0 = 0.04
  y0 = 0.0225
  z0 = 0.102
  mindist = HUGE( mindist )
		   DO l=1,CurrentModel % MaxElementNodes,1      
             jx = Model % Mesh % Nodes % x(l)
             jy = Model % Mesh % Nodes % y(l)
             jz = Model % Mesh % Nodes % z(l)          
             dist = (x0-jx)**2 + (y0-jy)**2 + (z0-jz)**2
             IF( dist < mindist ) THEN
               mindist = dist
               HeatControlNode = l  
             END IF
		   if (mindist<=0.00001)exit
           END DO
  Temp = localTemp(HeatControlNode)
  
!"Div Poynting Vector re" as the heat source variable
  Poyvar => VariableGet( Model % Mesh % Variables,'Div Poynting Vector re')
  Poy = Poyvar % Values(Poyvar % Perm(n))
  hvar = abs(Poy)/1050
  
  hcon = -4761.9
  tlimit = 600.0
  ht=hcon+hvar
  if (Temp <= tlimit) ht=hcon+hvar
  if(Temp > tlimit)  ht = hcon
  
  PRINT *, "heatsource",ht
  PRINT *, "HeatControlNode Temperature",Temp
  PRINT *, "HeatControlNode",HeatControlNode
  PRINT *, "HeatControlNode Coordinate", Model % Nodes % x(HeatControlNode)&
  , Model % Nodes % y(HeatControlNode), Model % Nodes % z(HeatControlNode)
END FUNCTION heatsource

Code: Select all

Heat Source = Variable  "Div Poynting Vector re,Temperature"
Real Procedure "heatsource" "heatsource"
So I let the udf output these values.

Code: Select all

 PRINT *, "heatsource",ht
  PRINT *, "HeatControlNode Temperature",Temp
  PRINT *, "HeatControlNode",HeatControlNode
  PRINT *, "HeatControlNode Coordinate", Model % Nodes % x(HeatControlNode)&
  , Model % Nodes % y(HeatControlNode), Model % Nodes % z(HeatControlNode)
The Solver log keeps outputting these values and finally gets stuck.I don't understand why there are so many HeatControlNode, shouldn' t there be just one?
Solver log.png
Solver log.png (168.98 KiB) Viewed 591 times
I really don't know what to do.
Best wishes,
Dustin
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Heat source for microwave heating

Post by kevinarden »

In my test run the heat control node stayed constant. Can you post the whole sif?
elelel
Posts: 32
Joined: 23 May 2022, 17:37
Antispam: Yes

Re: Heat source for microwave heating

Post by elelel »

Hi Kevin
case.sif
(6.2 KiB) Downloaded 62 times
Attachments
heatsource.F90
(3.12 KiB) Downloaded 49 times
0008.7z
(933.12 KiB) Downloaded 46 times
elelel
Posts: 32
Joined: 23 May 2022, 17:37
Antispam: Yes

Re: Heat source for microwave heating

Post by elelel »

This is the result of Comsol at 10s.
comsol—10s.png
comsol—10s.png (43.11 KiB) Viewed 570 times
This is Elmer's.
Elmer-10s.png
Elmer-10s.png (13.65 KiB) Viewed 570 times
The potato temperature is indeed less than 600K, but the whole potato is more than 550K, which should be wrong.
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Heat source for microwave heating

Post by kevinarden »

distance is the square root of this function

dist = (x0-jx)**2 + (y0-jy)**2 + (z0-jz)**2

in a spreadsheet
without the square root the mindist node is reported as 2 (coordinates 0,0,0) a distance of -0.39
which is actually the farthest one away but in the negative direction so mindist is report as the smallest

with
dist = sqrt((x0-jx)**2 + (y0-jy)**2 + (z0-jz)**2)
mindist is 0 at node
14137 coordinates 0.04, 0.0225, 0.102
elelel
Posts: 32
Joined: 23 May 2022, 17:37
Antispam: Yes

Re: Heat source for microwave heating

Post by elelel »

Hi Kevin,
When dist = (x0-jx)**2 + (y0-jy)**2 + (z0-jz)**2,shouldn't the distance always be positive? Why is there a -0.39?
I added "sqrt" but the result didn t change.
With sqrt or no sqrt, shouldn't it be the same result?
When I use this node 14137 directly,

Code: Select all

            ! dist = sqrt((x0-jx)**2 + (y0-jy)**2 + (z0-jz)**2)
             ! IF( dist < mindist ) THEN
               ! mindist = dist
               ! HeatControlNode = l  
             ! END IF
			 ! if (mindist<=0.001)exit
           ! END DO
  Temp = localTemp(14137)
it goes wrong.

Code: Select all

Backtrace for this error:
#0  0xffffffff
#1  0xffffffff
#2  0xffffffff
#3  0xffffffff
#4  0xffffffff
#5  0xffffffff
#6  0xffffffff
#7  0xffffffff
#8  0xffffffff
#9  0xffffffff
#10  0xffffffff
#11  0xffffffff
#12  0xffffffff
#13  0xffffffff
#14  0xffffffff
#15  0xffffffff
#16  0xffffffff
#17  0xffffffff
#18  0xffffffff
#19  0xffffffff
#20  0xffffffff
#21  0xffffffff
#22  0xffffffff
HeatSolve: Assembly done
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Heat source for microwave heating

Post by kevinarden »

True must be a error in the spreadsheet. However it appears that the closest node is not being found by the user function. It should be node 14137 based on the mesh.node file
elelel
Posts: 32
Joined: 23 May 2022, 17:37
Antispam: Yes

Re: Heat source for microwave heating

Post by elelel »

So can I still use the udf to find this point?
In the loop statement,
use

Code: Select all

DO l=1,CurrentModel % MaxElementNodes
find nodes 1,2,3,4 and it can control the temperature not exceeding 600K
use

Code: Select all

DO l=1,Model % NumberOfNodes
find nodes 1549,2138,1258,2546,145,2231,2057et al and it can not control the temperature
I also see

Code: Select all

TYPE(Nodes_t) :: Nodes
 CALL GetElementNodes( Nodes )
and the node "n" in the udf

Code: Select all

FUNCTION MyFunction(Model, n, f) RESULT(g)
Are they any different?Which one should I use to find this point?
Kevin,do you have any suggestions for my wrong simulation results? Is there any other error in my udf, except that it may not find this point?
I have been stopped here for many days.
I hope you don't mind me asking so many questions.
Thank you!
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Heat source for microwave heating

Post by kevinarden »

Have been doing some testing and it appears the function is evaluating each element indivudually, MaxElementNodes is the maximum number of nodes for the current element. The function is finding the closest node to the desired point for the current element and setting temperature and heat input based on that. I think your intent was to find the closest node in the whole mesh and set heat based on that temperature. That is not happening.
kevinarden
Posts: 2237
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Heat source for microwave heating

Post by kevinarden »

Hard coding it to node 14137 did not end in an error for me and the result after 1 sec is closer to the comsol
1sec.png
1sec.png (75.13 KiB) Viewed 515 times
Post Reply