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 Peter,
I understand.I will try new simulations with serial first.
I am learning about MPI programming.I would like to confirm the general direction of learning.
I need to add MPI_Send() after the Temp is it?for instance

Code: Select all

Temp = TmpVar % Values(TmpVar % Perm(HeatControlNode))
MPI_Send(buf,count,datatype,dest,tag,comm,ierr)
I'll learn for a while before I ask you.
Thank you Peter!
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Heat source for microwave heating

Post by raback »

Hi

MPI is not that easy. You need to explicitly sent information from the owner of the control node and recieve it on the other processes. So you always need to have both sent and recv statements. You can do this also by parallel reduction operators, in Elmer there are wrappers for this, grep the code base for "ParallelReduction".

However, the MPI needs always same processes to be launched at each node. So a caveat in this case is that if you do not have the "heat source" active in every partition some processes will not launch the code at all and the routine will fail. Hence ideally the control temperature should be define outside the UDF to overcome this problem. I might make a small remedy here.

-Peter
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Heat source for microwave heating

Post by raback »

Hi,

Ok. I made a small addition to the code that creates explicit controls on given coordinates that the user can use as he wishes.

A test case to illuminate this is given here:
https://github.com/ElmerCSC/elmerfem/tr ... olExplicit

You must of course have a very fresh Elmer as this feature is ~10 minutes old now.

-Peter
elelel
Posts: 32
Joined: 23 May 2022, 17:37
Antispam: Yes

Re: Heat source for microwave heating

Post by elelel »

Dear Peter,
That's awesome!!!
:?: Can the cpar directly obtain the temperature of the control point?
If it can it seems ok not to use udf,like

Code: Select all

Heat Source = Variable "cpar,time,Div Poynting Vector re"
Real MATC "if(tx(0)<600) abs(tx(2))/1050-4761.9;else -4761.9;"
However,the cpar is cooling down.
:?: My udf is like this

Code: Select all

FUNCTION AlternatingSource(Model, n, x) RESULT(ht)
  USE DefUtils
  
  IMPLICIT None
  
  TYPE(Model_t) :: Model
  INTEGER :: n
  REAL(KIND=dp) :: x(2),ht
  
  TYPE(Variable_t), POINTER :: PoyVar,TmpVar
  REAL(KIND=dp) :: hvar,tlimit,hcon,time,tpoint,Poy
   
  tpoint = x(1)
  time = x(2)
  
  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 (tpoint <= tlimit) then
  ht = hcon + hvar
  else
  ht = hcon 
  end if 
    
END FUNCTION AlternatingSource

Code: Select all

Body Force 1
  Name = "Body Force 1"
Heat Source = Variable "cpar,time"
Real Procedure "AlternatingSource" "AlternatingSource"
End
The cpar is also cooling down.
Where did I do it wrong?I don't know how to output the "Control Node".

Code: Select all

   1: value: cpar scalar variable
   2: min: temperature
   3: max: temperature
   4: res: energy functional
   5: res: energy functional im
   6: res: integral of div poynting vector
   7: res: integral of div poynting vector im

   2.882617911464E+002   2.881196149044E+002   4.657663500887E+002   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.882617911464E+002   2.881196149040E+002   4.657663500889E+002   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.835235822981E+002   2.833215529593E+002   6.238696959501E+002   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.835235822981E+002   2.833215529593E+002   6.238696959501E+002   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.787853734648E+002   2.787525679870E+002   7.716777643860E+002   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.787853734648E+002   2.787525679870E+002   7.716777643860E+002   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.740471646704E+002   2.740188638475E+002   9.095108828271E+002   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.740471646704E+002   2.740188638475E+002   9.095108828272E+002   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.693089559758E+002   2.693088396988E+002   1.039593507943E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.693089559758E+002   2.693088396988E+002   1.039593507943E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.645707475406E+002   2.645707426069E+002   1.163721239813E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.645707475406E+002   2.645707426069E+002   1.163721239813E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.598325397845E+002   2.598325241430E+002   1.283215686876E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.598325397845E+002   2.598325241430E+002   1.283215686876E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.550943338209E+002   2.550943017185E+002   1.399023026161E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.550943338209E+002   2.550943017185E+002   1.399023026161E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.503561325543E+002   2.503561030315E+002   1.511820537330E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.503561325543E+002   2.503561030315E+002   1.511820537330E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.456179431772E+002   2.456179062392E+002   1.622099815974E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.456179431772E+002   2.456179062392E+002   1.622099815974E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.408797821107E+002   2.408797010383E+002   1.730225565664E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
   2.408797821107E+002   2.408797010383E+002   1.730225565664E+003   1.772125454693E+013  -5.315369959778E+014  -6.298030660700E+002  -5.755972840402E+002
AlternatingSource.F90
(606 Bytes) Downloaded 59 times
coarsemesh.mphtxt
(416.16 KiB) Downloaded 45 times
Attachments
case.sif
(6.17 KiB) Downloaded 60 times
elelel
Posts: 32
Joined: 23 May 2022, 17:37
Antispam: Yes

Re: Heat source for microwave heating

Post by elelel »

Hi Peter,
I think FindClosestNode() didn't find the right MinNode.
This is Body Force 1

Code: Select all

Heat Source = Variable "cpar,time,Div Poynting Vector re "
Real MATC "if(tx(0)<600) abs(tx(2))/1050-4761.9;else -4761.9;"
I think the ControlNode is in the air, not near the Control Node Coordinates(1,2,3) = Real 0.04 0.0225 0.102
When both body1(Air) and body2(potato) have Body Force 1, the value of cpar keeps falling.Because the heat source of the air is-4761.9.
When only body2(potato) has Body Force 1, the value of cpar remains unchanged at 293K.Because the air has no heat source, it is the initial temperature.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Heat source for microwave heating

Post by raback »

Hi,

Try this one:

Code: Select all

ElmerGrid 9 2 coarsemesh.mphtxt
elmerf90 -o AlternatingSource.so AlternatingSource.F90 
ElmerSolver case.sif
Maybe I don't use the control temperature in the correct way. However, seems to give same results in serial and parallel.

-Peter
Attachments
AlternatingSource.F90
(701 Bytes) Downloaded 63 times
case.sif
(5.63 KiB) Downloaded 60 times
elelel
Posts: 32
Joined: 23 May 2022, 17:37
Antispam: Yes

Re: Heat source for microwave heating

Post by elelel »

Dear Peter,
The temperature control is successful!!!
I’d like to say a BIG THANK YOU to you for your extremely awesome Explicit Control and udf.
Seeing the sif you sent me,I found that I wrote the control node coordinates (1,2,3) instead of the control node coordinates (1,3).Maybe that's why it didn't find the ControlNode.
Sorry, Peter, I thought that Control Node Coordinates (1,2,3) was "a" mean "(x, y, z)", and now I know it is an array.Really sorry for wasting your time.
I used your udf but it doesn't heat up after tpoint=600. So I used your last AlternatingSource.F90 instead of this. I learned the usage of "return" from this udf though.Really sorry I made this really stupid mistake.
You helped me do the majority of this simulation.I really can't express my gratitude in words.The experts at Elmer are really so good.
Best wishes
Dustin
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Heat source for microwave heating

Post by raback »

Hi Dustin,

Maybe you can provide some nice final results (with the finer mesh) or cross comparison with Comsol. That would probably be appreciated by many users.

-Peter
elelel
Posts: 32
Joined: 23 May 2022, 17:37
Antispam: Yes

Re: Heat source for microwave heating

Post by elelel »

Hi Peter,
Okay, I'll do it right now!
Last edited by elelel on 04 Aug 2022, 18:42, edited 2 times in total.
raback
Site Admin
Posts: 4812
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

Re: Heat source for microwave heating

Post by raback »

Hi,

I could give you commit access here:
https://github.com/ElmerCSC/elmer-elmag

I think this fits nicely the collection of more advanced problems related to electromagnetics.

-Peter
Post Reply