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"
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)
Best wishes,
Dustin