Issue with User-Defined Function - Heat Source depending on Coordinates

Numerical methods and mathematical models of Elmer
Post Reply
ftrillaudp
Posts: 42
Joined: 23 May 2012, 05:26
Antispam: Yes

Issue with User-Defined Function - Heat Source depending on Coordinates

Post by ftrillaudp »

Dear all,

I am trying to define a local heat dissipation through a Heat Source which depends on space location and time. Thus far, I am working only on the spatial distribution of the heat source in a racetrack coil.
The heat is dissipated in a sphere of radius R so that R is larger than the distance between nodes. I compute the distance between the center of the sphere and any points in the mesh of the racetrack. Assuming Pd(x_d,y_d,z_d), the center of the sphere, the distance d to any points P(x,y,z) is given by: d = SQRT((x-x_d)^2+(y-y_d)^2+(z-z_d)^2). I impose a condition on d and R, If (d > R) then there is no dissipation Q = 0 else Q is equal to a given value Qd.

I have implemented the scheme in an UDF. However, it does not seem to work properly and I am wondering if I am using the proper coordinate system points (x, y, z). I have attached the UDF and the case.sif file as well as a result to show the issue. The heat source is not located at the expected position in the racetrack coil.

I have tried to change the size of the mesh but the issue persists. I am stuck at this point.

The UDF with additional comments is also given below:

FUNCTION getDisturbance(Model, n, tt) RESULT(Q)
! Elmer module
USE DefUtils

IMPLICIT NONE
TYPE(Model_t) :: model
INTEGER :: n
REAL(KIND=dp) :: tt
REAL(KIND=dp) :: X, Y, Z, t_ini, Dt, Qd, Q
REAL(KIND=dp) :: R, x_d, y_d, z_d, d

t_ini = 0.003
Dt = 0.01
Qd = 7000.0

! get local coordinates of the nodes
X = model % Nodes % x(n)
Y = model % Nodes % y(n)
Z = model % Nodes % z(n)

! Half side length of the cubic disturbance
R = 0.007 ! distance between node of the order of 0.005 m
! Center of the disturbance:
x_d = 0.0
y_d = -0.026 ! somewhere in the middle of the straight section of the racetrack
z_d = 0.0
! distance to center of disturbance
d = SQRT((X-x_d)**2+(Y-y_d)**2+(Z-y_d)**2)

PRINT 1,(R-d)
1 FORMAT(' R-d: ', EN12.3)

IF (d > R) THEN
Q = 0.0D00
ELSE
Q = Qd
PRINT *, "ON POINT"
END IF

END FUNCTION getDisturbance


Best,

Frederic
Attachments
resultsParaView.png
Wrong location of heat source
(555.87 KiB) Not downloaded yet
case.sif
sif file calling in Body Force 1, the function
(9.81 KiB) Downloaded 211 times
disturbance.F90
F90 UDF
(891 Bytes) Downloaded 214 times
kevinarden
Posts: 2301
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: Issue with User-Defined Function - Heat Source depending on Coordinates

Post by kevinarden »

Would need the mesh to check.
ftrillaudp
Posts: 42
Joined: 23 May 2012, 05:26
Antispam: Yes

Re: Issue with User-Defined Function - Heat Source depending on Coordinates

Post by ftrillaudp »

Here is the mesh at:

https://drive.google.com/file/d/1PtfS7f ... sp=sharing

I am adding the material properties as well. These are tables in a subfolder:

https://drive.google.com/file/d/1getvP9 ... sp=sharing


Best,

Frederic
ftrillaudp
Posts: 42
Joined: 23 May 2012, 05:26
Antispam: Yes

Re: Issue with User-Defined Function - Heat Source depending on Coordinates

Post by ftrillaudp »

I have found my mistake. It was a simple typo in the computation of the distance d, instead of the correct d = SQRT((X-x_d)**2+(Y-y_d)**2+(Z-z_d)**2), the code read d = SQRT((X-x_d)**2+(Y-y_d)**2+(Z-y_d)**2) a typo in the last square!

It works now.

Thanks for replying, best,

Frederic
Post Reply