Skip to content

Commit bf92c5b

Browse files
committed
bugfixes; add test for linear profile
1 parent f9ce070 commit bf92c5b

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

src/Setup_geometry.jl

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,17 @@ end
11001100
"""
11011101
LinearWeightedTemperature
11021102
1103-
Weight average structure -> correction from previous version Boris Kaus
1103+
Structure that defined a linear average temperature between two temperature fields as a function of distance
1104+
1105+
Parameters
1106+
===
1107+
- w_min: Minimum weight
1108+
- w_max: Maximum weight
1109+
- crit_dist: Critical distance
1110+
- dir: Direction of the averaging (`:X`, `:Y` or `:Z`)
1111+
- F1: First temperature field
1112+
- F2: Second temperature field
1113+
11041114
"""
11051115
@with_kw_noshow mutable struct LinearWeightedTemperature <: AbstractThermalStructure
11061116
w_min::Float64 = 0.0;
@@ -1136,23 +1146,23 @@ function Compute_ThermalStructure(Temp, X, Y, Z, Phase, s::LinearWeightedTempera
11361146
end
11371147

11381148
# compute the 1D thermal structures
1139-
Temp1 = Compute_ThermalStructure(Temp, X, Y, Z, Phase, F1);
1140-
1141-
Temp2 = Compute_ThermalStructure(Temp, X, Y, Z, Phase, F2);
1149+
Temp1 = zeros(size(Temp));
1150+
Temp2 = zeros(size(Temp));
1151+
Temp1 = Compute_ThermalStructure(Temp1, X, Y, Z, Phase, F1);
1152+
Temp2 = Compute_ThermalStructure(Temp2, X, Y, Z, Phase, F2);
11421153

11431154
# Compute the weights
11441155
weight = w_min .+(w_max-w_min) ./(crit_dist) .*(dist)
11451156

11461157
ind_1 = findall(weight .>w_max);
1147-
1148-
ind_2 =findall(weight .<w_min);
1158+
ind_2 = findall(weight .<w_min);
11491159

11501160
# Change the weight
11511161
weight[ind_1] .= w_max;
1152-
11531162
weight[ind_2] .= w_min;
1163+
1164+
# Average temperature
1165+
Temp .= Temp1 .*(1.0 .- weight) + Temp2 .* weight;
11541166

1155-
# Average
1156-
Temp = Temp1 .*weight+ Temp2 .*(1.0 - weight);
11571167
return Temp
11581168
end

test/test_setup_geometry.jl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,24 @@ Temp = ones(Float64,size(Cart))*1350;
190190
AddBox!(Phase, Temp, Cart; xlim=(0.0,600.0),ylim=(0.0,600.0), zlim=(-80.0, 0.0), phase = ConstantPhase(5), T=TsMK);
191191
@test sum(Temp) 3.518172093383281e8
192192

193-
# inclined
193+
# inclined slab
194194
Temp = ones(Float64,size(Cart))*1350;
195195
AddBox!(Phase, Temp, Cart; xlim=(0.0,600.0),ylim=(0.0,600.0), zlim=(-80.0,0),StrikeAngle=0, DipAngle=45, phase = ConstantPhase(5), T=TsMK);
196196
@test sum(Temp) 3.5133669349123573e8
197197

198198

199-
# T_slab = LinearWeightedTemperature(0.1,1.0,100.0,:X,TsMK,TsHC);
200199

201-
# AddBox!(Phase, Temp, Cart; xlim=(0.0,600.0),ylim=(0.0,600.0), zlim=(0.0,-80.0),StrikeAngle=0, DipAngle=45, phase = ConstantPhase(5), T=McKenzie(20.0));
200+
# horizontal slab, constant T
201+
T_slab = LinearWeightedTemperature(0,1,600.0,:X,ConstantTemp(1000), ConstantTemp(2000));
202+
Temp = ones(Float64,size(Cart))*1350;
203+
AddBox!(Phase, Temp, Cart; xlim=(0.0,600.0),ylim=(0.0,600.0), zlim=(-80.0, 0.0), phase = ConstantPhase(5), T=T_slab);
204+
@test sum(Temp) 3.549127111111111e8
205+
206+
# horizontal slab, halfspace and McKenzie
207+
T_slab = LinearWeightedTemperature(crit_dist=600, F1=TsHC, F2=TsMK);
208+
Temp = ones(Float64,size(Cart))*1350;
209+
AddBox!(Phase, Temp, Cart; xlim=(0.0,600.0),ylim=(0.0,600.0), zlim=(-80.0, 0.0), phase = ConstantPhase(5), T=T_slab);
210+
@test sum(Temp) 3.499457641038468e8
211+
202212

203-
# Data_Final = CartData(X,Y,Z,(Phase=Phase,Temp=Temp))
213+
Data_Final = AddField(Cart,"Temp",Temp)

0 commit comments

Comments
 (0)