-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththermal.py
More file actions
executable file
·1188 lines (1017 loc) · 64.2 KB
/
thermal.py
File metadata and controls
executable file
·1188 lines (1017 loc) · 64.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import torch
from sympy import Symbol, And, LessThan, sqrt, StrictLessThan, GreaterThan, StrictGreaterThan, Not
import numpy as np
import os
import modulus
from modulus.sym.hydra.config import ModulusConfig
from modulus.sym.hydra import to_absolute_path
from csv_rw_skiprows import csv_to_dict
from modulus.sym.solver import Solver
from modulus.sym.domain import Domain
from modulus.sym.domain.constraint import (
PointwiseBoundaryConstraint,
PointwiseInteriorConstraint,
PointwiseConstraint
)
from modulus.sym.domain.monitor import PointwiseMonitor
from modulus.sym.key import Key
from modulus.sym.node import Node
from modulus.sym.models.fourier_net import FourierNetArch
from modulus.sym.eq.non_dim import Scaler
from modulus.sym.eq.pdes.basic import GradNormal
from basicS import NormalDotVec
from modulus.sym.eq.pdes.diffusion import Diffusion, DiffusionInterface
from modulus.sym.eq.pdes.advection_diffusion import AdvectionDiffusion
from advection_diffusion_s import AdvectionDiffusionS
from diffusion_s import DiffusionInterfaceHTC
from channelProperties import *
from coolingProperties import *
from geometry import dLightGeo
from ansysValidator import ansysValidator
def modHeat(designs=[]):
@modulus.sym.main(config_path="conf", config_name="conf_thermal")
def run(cfg: ModulusConfig) -> None:
# --------------------------------------------------------------------Thermal Equations--------------------------------------------------------------------
ad = AdvectionDiffusion(T="theta_f", rho=nd_fluid_density_ch, D=nd_fluid_diffusivity_ch, dim=3, time=False)
ad_co = AdvectionDiffusionS(domain="co", T="theta_fco", rho=nd_fluid_density_ch, D=nd_fluid_diffusivity_ch, dim=3, time=False)
ad_co2 = AdvectionDiffusionS(domain="co2", T="theta_fco2", rho=nd_fluid_density_ch, D=nd_fluid_diffusivity_ch, dim=3, time=False)
dif = Diffusion(T="theta_s", D=nd_solid_diffusivity, dim=3, time=False)
dif_inteface = DiffusionInterface("theta_f", "theta_s", nd_fluid_diffusivity_ch, nd_solid_diffusivity, dim=3, time=False)
dif_intefaceHTC = DiffusionInterfaceHTC("theta_s", nd_channel_inlet_temp, nd_solid_diffusivity, nd_channel_HTC, dim=3, time=False)
dif_inteface_co = DiffusionInterface("theta_fco", "theta_s", nd_fluid_diffusivity_ch, nd_solid_diffusivity, dim=3, time=False)
dif_inteface_co2 = DiffusionInterface("theta_fco2", "theta_s", nd_fluid_diffusivity_ch, nd_solid_diffusivity, dim=3, time=False)
f_grad = GradNormal("theta_f", dim=3, time=False)
f_grad_co = GradNormal("theta_fco", dim=3, time=False)
f_grad_co2 = GradNormal("theta_fco2", dim=3, time=False)
s_grad = GradNormal("theta_s", dim=3, time=False)
# --------------------------------------------------------------------Flow Equations--------------------------------------------------------------------
normal_dot_vel_scaled_co1 = NormalDotVec(["u_co_scaled", "v_co_scaled", "w_co_scaled"], domainName="_scaled_co1")
normal_dot_vel_scaled_co2 = NormalDotVec(["u_co2_scaled", "v_co2_scaled", "w_co2_scaled"], domainName="_scaled_co2")
# --------------------------------------------------------------------Channel: Networks and Nodes--------------------------------------------------------------------
# Channel Flow
# Net
input_keys = [Key("x"), Key("y"), Key("z")]
output_keys = [Key("u"), Key("v"), Key("w"), Key("p")]
flow_net = FourierNetArch(
input_keys=input_keys,
output_keys=output_keys,
adaptive_activations=False,
)
# Scaling Nodes
# Output
equation_nodes = Scaler(
["u", "v", "w", "p"],
["u_scaled", "v_scaled", "w_scaled", "p_scaled"],
["m/s", "m/s", "m/s", "pascal"],
channelNonDim).make_node()
# Channel Thermal
# Net
input_keys = [Key("x"), Key("y"), Key("z"), Key("holeRadius1_s"), Key("inletVelocity1_s"), Key("holePosX1_s"), Key("holePosZ1_s"), Key("holeRadius2_s"), Key("inletVelocity2_s"), Key("holePosX2_s"), Key("holePosZ2_s")]
thermal_f_net = FourierNetArch(
input_keys=input_keys,
output_keys=[Key("theta_f")],
frequencies=("axis", [i/2 for i in range(32)]),
frequencies_params=("axis", [i/2 for i in range(32)]),
adaptive_activations=True,
layer_size=512,
nr_layers=6
)
# Scaling Nodes
# Output
equation_nodes += Scaler(
["theta_f"],
["theta_f_scaled"],
["K"],
channelNonDim).make_node()
# --------------------------------------------------------------------Cooling Holes: Networks and Nodes--------------------------------------------------------------------
# Scales for Normalization
channelToCoolingLengthScale = length_scale_ch.magnitude/length_scale.magnitude
coolingToChannelVelocityScale = velocity_scale.magnitude/velocity_scale_ch.magnitude
# Cooling Hole 1
# Cooling Hole 1 Flow
# Net
input_keys_co = [Key("x_s"), Key("y_s"), Key("holeRadius1_s"), Key("inletVelocity1_s")]
output_keys_co = [Key("u_s_co"), Key("v_s_co"), Key("p_s_co")]
flow_net_co = FourierNetArch(
input_keys=input_keys_co,
output_keys=output_keys_co,
)
# Scaling Nodes
# Input
equation_nodes += [
Node.from_sympy(y*channelToCoolingLengthScale, "x_s") #rotated to xyPlane
] + [Node.from_sympy(sqrt(((x-holePosX1)*channelToCoolingLengthScale)**2 + ((z-holePosZ1)*channelToCoolingLengthScale)**2), "y_s")
] + [Node.from_sympy(holeRadius1*channelToCoolingLengthScale, "holeRadius1_s")
] + [Node.from_sympy(inletVelocity1/coolingToChannelVelocityScale, "inletVelocity1_s")
] + [Node.from_sympy(holePosX1*channelToCoolingLengthScale, "holePosX1_s")
] + [Node.from_sympy(holePosZ1*channelToCoolingLengthScale, "holePosZ1_s")]
# Output
equation_nodes += [Node.from_sympy(Symbol("u_s_co")*coolingToChannelVelocityScale, "v_co")
] + [Node.from_sympy(Symbol("v_s_co")*coolingToChannelVelocityScale, "u_co")
] + [Node.from_sympy(Symbol("v_s_co")*coolingToChannelVelocityScale, "w_co")
] + [Node.from_sympy(Symbol("p_s_co")*(density_scale.magnitude*velocity_scale.magnitude**2)/(density_scale_ch.magnitude*velocity_scale_ch.magnitude**2), "p_co")]
equation_nodes += Scaler(
["u_co", "v_co", "w_co", "p_co"],
["u_co_scaled", "v_co_scaled", "w_co_scaled", "p_co_scaled"],
["m/s", "m/s", "m/s", "pascal"],
channelNonDim).make_node()
equation_nodes += Scaler(
["area"],
["area_scaled"],
["m"],
coolingNonDim).make_node()
# Cooling Hole 1 Thermal
# Net
input_keys = [Key("x_st"), Key("y"), Key("z_st"), Key("holeRadius1_s"), Key("inletVelocity1_s"), Key("holePosX1_s"), Key("holePosZ1_s"), Key("holeRadius2_s"), Key("inletVelocity2_s"), Key("holePosX2_s"), Key("holePosZ2_s")]
thermal_f_net_co = FourierNetArch(
# thermal_f_net_co = FullyConnectedArch(
input_keys=input_keys,
output_keys=[Key("theta_fco")],
frequencies=("axis", [i/2 for i in range(16)]),
frequencies_params=("axis", [i/2 for i in range(16)]),
adaptive_activations=True,
layer_size=256,
nr_layers=4
)
# Scaling Nodes
# Input
equation_nodes += [
Node.from_sympy((x-holePosX1)/(2*holeRadius1), "x_st")
] + [Node.from_sympy((z-holePosZ1)/(2*holeRadius1), "z_st")]
#Output
equation_nodes += Scaler(
["theta_fco", "theta_s"],
["theta_fco_scaled", "theta_s_scaled"],
["K", "K"],
channelNonDim).make_node()
# Cooling Hole 2
# Cooling Hole 2 Flow
# Net
input_keys_co2 = [Key("x_s"), Key("y_s2"), Key("holeRadius2_s"), Key("inletVelocity2_s")]
output_keys_co2 = [Key("u_s_co2"), Key("v_s_co2"), Key("p_s_co2")]
flow_net_co2 = FourierNetArch(
input_keys=input_keys_co2,
output_keys=output_keys_co2
)
# Scaling Nodes
# Input
equation_nodes += [
Node.from_sympy(sqrt(((x-holePosX2)*channelToCoolingLengthScale)**2 + ((z-holePosZ2)*channelToCoolingLengthScale)**2), "y_s2")
] + [Node.from_sympy(holeRadius2*channelToCoolingLengthScale, "holeRadius2_s")
] + [Node.from_sympy(inletVelocity2/coolingToChannelVelocityScale, "inletVelocity2_s")
] + [Node.from_sympy(holePosX2*channelToCoolingLengthScale, "holePosX2_s")
] + [Node.from_sympy(holePosZ2*channelToCoolingLengthScale, "holePosZ2_s")]
# Output
equation_nodes += [Node.from_sympy(Symbol("u_s_co2")*coolingToChannelVelocityScale, "v_co2")
] + [Node.from_sympy(Symbol("v_s_co2")*coolingToChannelVelocityScale, "u_co2")
] + [Node.from_sympy(Symbol("v_s_co2")*coolingToChannelVelocityScale, "w_co2")
] + [Node.from_sympy(Symbol("p_s_co2")*(density_scale.magnitude*velocity_scale.magnitude**2)/(density_scale_ch.magnitude*velocity_scale_ch.magnitude**2), "p_co2")]
equation_nodes += Scaler(
["u_co2", "v_co2", "w_co2", "p_co2"],
["u_co2_scaled", "v_co2_scaled", "w_co2_scaled", "p_co2_scaled"],
["m/s", "m/s", "m/s", "pascal"],
channelNonDim).make_node()
# Cooling Hole 2 Thermal
# Net
input_keys = [Key("x_st2"), Key("y"), Key("z_st2"), Key("holeRadius2_s"), Key("inletVelocity2_s"), Key("holePosX2_s"), Key("holePosZ2_s"), Key("holeRadius1_s"), Key("inletVelocity1_s"), Key("holePosX1_s"), Key("holePosZ1_s")]
thermal_f_net_co2 = FourierNetArch(
# thermal_f_net_co2 = FullyConnectedArch(
input_keys=input_keys,
output_keys=[Key("theta_fco2")],
frequencies=("axis", [i/2 for i in range(16)]),
frequencies_params=("axis", [i/2 for i in range(16)]),
adaptive_activations=True,
layer_size=256,
nr_layers=4
)
#Scaling Nodes
# Input
equation_nodes += [
Node.from_sympy((x-holePosX2)/(2*holeRadius2), "x_st2")
] + [Node.from_sympy((z-holePosZ2)/(2*holeRadius2), "z_st2")]
# Output
equation_nodes += Scaler(
["theta_fco2"],
["theta_fco2_scaled"],
["K"],
channelNonDim).make_node()
# --------------------------------------------------------------------Solid: Networks and Nodes--------------------------------------------------------------------
# Solid Thermal
# Net
input_keys = [Key("x"), Key("y"), Key("z"), Key("holeRadius1_s"), Key("inletVelocity1_s"), Key("holePosX1_s"), Key("holePosZ1_s"), Key("holeRadius2_s"), Key("inletVelocity2_s"), Key("holePosX2_s"), Key("holePosZ2_s")]
thermal_s_net = FourierNetArch(
input_keys=input_keys,
output_keys=[Key("theta_s")],
frequencies=("axis", [i/2 for i in range(16)]),
frequencies_params=("axis", [i/2 for i in range(16)]),
adaptive_activations=True,
layer_size=512,
nr_layers=6
)
# --------------------------------------------------------------------Full List of Nodes--------------------------------------------------------------------
solidNodes = (
[thermal_s_net.make_node(name="thermal_s_network", optimize=cfg.custom.optimizeTs)]
+ s_grad.make_nodes()
+ [thermal_s_net.make_node(name="thermal_s_network", optimize=cfg.custom.optimizeTs)]
+ dif.make_nodes())
if cfg.custom.useHTC:
solidNodes += dif_intefaceHTC.make_nodes()
channelNodes = (
ad.make_nodes()
+ f_grad.make_nodes()
+ [thermal_f_net.make_node(name="thermal_f_network", optimize=cfg.custom.optimizeTf)]
+ [flow_net.make_node(name="flow_network", optimize=False)])
if not cfg.custom.useHTC:
channelNodes += dif_inteface.make_nodes()
coolingHole1Nodes = (
ad_co.make_nodes()
+ dif_inteface_co.make_nodes()
+ f_grad_co.make_nodes()
+ normal_dot_vel_scaled_co1.make_nodes()
+ [flow_net_co.make_node(name="flow_network_co", optimize=False)]
+ [thermal_f_net_co.make_node(name="thermal_f_network_co", optimize=cfg.custom.optimizeTfco1)])
coolingHole2Nodes = (
ad_co2.make_nodes()
+ dif_inteface_co2.make_nodes()
+ f_grad_co2.make_nodes()
+ normal_dot_vel_scaled_co2.make_nodes()
+ [flow_net_co2.make_node(name="flow_network_co2", optimize=False)]
+ [thermal_f_net_co2.make_node(name="thermal_f_network_co2", optimize=cfg.custom.optimizeTfco2)])
thermal_nodes = (
equation_nodes
+ solidNodes
+ channelNodes
+ coolingHole1Nodes
+ coolingHole2Nodes
)
# --------------------------------------------------------------------Domain--------------------------------------------------------------------
thermal_domain = Domain()
# --------------------------------------------------------------------Geometry and Criterias for Constraints--------------------------------------------------------------------
geo = dLightGeo(paramRanges_ch)
def finInteriorCriteria(invar, params):
sdf = geo.finInteriorCriteriaGeo.sdf(invar, params)
return np.greater(sdf["sdf"], 0)
def finInteriorCriteria2(invar, params):
sdf = geo.finInteriorCriteriaGeo2.sdf(invar, params)
return np.greater(sdf["sdf"], 0)
def solidInteriorCriteria(invar, params):
sdf = geo.solidInteriorCsg.sdf(invar, params)
return np.greater(sdf["sdf"], 0)
def solidExteriorWallCriteria(invar, params):
sdf = geo.solidExteriorWallCriteriaGeo.sdf(invar, params)
return np.less(sdf["sdf"], 0)
def solidCriteria(invar, params):
sdf = geo.finExteriorCriteriaGeo.sdf(invar, params)
return np.less(sdf["sdf"], 0)
# --------------------------------------------------------------------Data Contstraints--------------------------------------------------------------------
if cfg.run_mode == "train" and (cfg.custom.includeData or cfg.custom.dataOnly):
def ansysDataConstraint(file_path, ansysVarNames, modulusVarNames, scales, batches, criteria={}):
if os.path.exists(to_absolute_path(file_path)):
mapping = {}
for ansVarName, modulusVarName in zip(ansysVarNames, modulusVarNames):
mapping[ansVarName] = modulusVarName
openfoam_var = csv_to_dict(to_absolute_path(file_path), mapping, skiprows=6)
if file_path.split("/")[5] == "co1":
print("co1")
openfoam_var["z"] = -openfoam_var["z"]
if file_path.split("/")[5] == "co2":
print("co2")
openfoam_var["z"] = -openfoam_var["z"]
for key, scale in zip(modulusVarNames, scales):
openfoam_var[key] /= scale
parameters = file_path.split("_")[1].split(".")[0].split("-")
dataParameterRanges = {
holeRadius1: (float(parameters[1]),"mm"),
holeRadius2: (float(parameters[0]), "mm"),
inletVelocity1: (float(parameters[6]), "m/s"),
inletVelocity2: (float(parameters[7]), "m/s"),
holePosX1: (float(parameters[4]), "mm"),
holePosX2: (-float(parameters[5]), "mm"),
holePosZ1: (float(parameters[2])-20, "mm"),
holePosZ2: (float(parameters[3])-20, "mm"),
}
specificParas = parameterRangeContainer(dataParameterRanges)
specificParas.nondim(channelNonDim)
parameterRanges = specificParas.maxval()
openfoam_var.update({"holeRadius1": np.full_like(openfoam_var["x"], parameterRanges[holeRadius1])})
openfoam_var.update({"holeRadius2": np.full_like(openfoam_var["x"], parameterRanges[holeRadius2])})
openfoam_var.update({"inletVelocity1": np.full_like(openfoam_var["x"], parameterRanges[inletVelocity1])})
openfoam_var.update({"inletVelocity2": np.full_like(openfoam_var["x"], parameterRanges[inletVelocity2])})
openfoam_var.update({"holePosX1": np.full_like(openfoam_var["x"], parameterRanges[holePosX1])})
openfoam_var.update({"holePosX2": np.full_like(openfoam_var["x"], parameterRanges[holePosX2])})
openfoam_var.update({"holePosZ1": np.full_like(openfoam_var["x"], parameterRanges[holePosZ1])})
openfoam_var.update({"holePosZ2": np.full_like(openfoam_var["x"], parameterRanges[holePosZ2])})
criteria = {"x":(-0.4, 0.4)}
invarKeys = ["x", "y", "z", "holeRadius1", "inletVelocity1", "holeRadius2", "inletVelocity2", "holePosX1", "holePosX2", "holePosZ1", "holePosZ2"]
outvarKeys = modulusVarNames[:-3]
openfoam_invar_numpy = {
key: value
for key, value in openfoam_var.items()
if key in invarKeys
}
openfoam_outvar_numpy = {
key: value for key, value in openfoam_var.items() if key in outvarKeys
}
for critKey in criteria.keys():
for outvKey in outvarKeys:
openfoam_outvar_numpy[outvKey] = openfoam_outvar_numpy[outvKey][(openfoam_invar_numpy[critKey]>criteria[critKey][0]) & (openfoam_invar_numpy[critKey]<criteria[critKey][1])][np.newaxis].T
for invKey in invarKeys:
if invKey != critKey:
openfoam_invar_numpy[invKey] = openfoam_invar_numpy[invKey][(openfoam_invar_numpy[critKey]>criteria[critKey][0]) & (openfoam_invar_numpy[critKey]<criteria[critKey][1])][np.newaxis].T
openfoam_invar_numpy[critKey] = openfoam_invar_numpy[critKey][(openfoam_invar_numpy[critKey]>criteria[critKey][0]) & (openfoam_invar_numpy[critKey]<criteria[critKey][1])][np.newaxis].T
# print(openfoam_var['x'].size)
dataConstraint = PointwiseConstraint.from_numpy(
nodes=thermal_nodes,
invar=openfoam_invar_numpy,
outvar=openfoam_outvar_numpy,
batch_size=int(openfoam_invar_numpy['x'].size/batches),
# lambda_weighting={"u": 0.1, "v": 0.1, "w": 0.1}
)
return dataConstraint
else:
print("Missing Data: ", file_path)
# ansysVarNames = ("Temperature [ K ]", "X [ m ]", "Y [ m ]", "Z [ m ]")
# scales = (temp_scale_ch.magnitude * 10, length_scale_ch.magnitude, length_scale_ch.magnitude, length_scale_ch.magnitude)
# modulusVarNames = ("theta_f_data", "x", "y", "z")
# batches = 1000
# for root, dirs, files in os.walk(to_absolute_path("./ansys/constraints")):
# for name in files:
# print(os.path.join(root, name))
# file_path = str(os.path.join(root, name))
# thermal_domain.add_constraint(ansysDataConstraint(file_path, ansysVarNames, modulusVarNames, scales, batches), name)
# ansysVarNames = ("Temperature [ K ]", "X [ m ]", "Y [ m ]", "Z [ m ]")
# scales = (temp_scale_ch.magnitude, length_scale_ch.magnitude, length_scale_ch.magnitude, length_scale_ch.magnitude)
# modulusVarNames = ("theta_fco", "x", "y", "z")
# batches = 10
# for root, dirs, files in os.walk(to_absolute_path("./ansys/constraints/co1")):
# for name in files:
# print(os.path.join(root, name))
# file_path = str(os.path.join(root, name))
# thermal_domain.add_constraint(ansysDataConstraint(file_path, ansysVarNames, modulusVarNames, scales, batches), name)
# ansysVarNames = ("Temperature [ K ]", "X [ m ]", "Y [ m ]", "Z [ m ]")
# scales = (temp_scale_ch.magnitude, length_scale_ch.magnitude, length_scale_ch.magnitude, length_scale_ch.magnitude)
# modulusVarNames = ("theta_fco2", "x", "y", "z")
# batches = 10
# for root, dirs, files in os.walk(to_absolute_path("./ansys/constraints/co2")):
# for name in files:
# print(os.path.join(root, name))
# file_path = str(os.path.join(root, name))
# thermal_domain.add_con4 layers of size 256 straint(ansysDataConstraint(file_path, ansysVarNames, modulusVarNames, scales, batches), name)
# --------------------------------------------------------------------Cooling Specific Thermal Contstraints--------------------------------------------------------------------
if cfg.run_mode == "train" and not cfg.custom.dataOnly:
if cfg.custom.optimizeTfco1:
coolingInlet = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.coolingInlet,
outvar={"theta_fco": nd_cooling_inlet_temp},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.inlet),
criteria=finInteriorCriteria,
parameterization=geo.pr,
lambda_weighting= {"theta_fco": 100},
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(coolingInlet, "coolingInlet")
# cooling outlet 1
coolingOutlet = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.coolingOutlet,
outvar={"normal_gradient_theta_fco": 0.0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.outlet),
lambda_weighting={"normal_gradient_theta_fco": 1},
criteria=finInteriorCriteria,
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(coolingOutlet, "coolingOutlet")
# cooling inlet walls insulating 1
coolingInletWall = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.finInteriorCriteriaGeo,
outvar={"normal_gradient_theta_fco": 0.0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.solidWall/2),
criteria=And(StrictLessThan(y, geo.nd_channel_origin[1]), StrictGreaterThan(y, geo.coolingInteriorBounds[1][0])),
lambda_weighting={"normal_gradient_theta_fco": 1},
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(coolingInletWall, "coolingInletWall")
# Cooling Hole Interior 1
#lambdaW = 0.5*tanh(100 * Symbol("sdf"))
fin_interior = PointwiseInteriorConstraint(
nodes=thermal_nodes,
geometry=geo.finInterior,
outvar={"advection_diffusion_theta_fco": 0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.holeInteriorHR),
lambda_weighting={"advection_diffusion_theta_fco": cfg.custom.adDifCo},
batch_per_epoch=cfg.batch_size.batchPerEpoch,
parameterization=geo.pr,
quasirandom=False
)
thermal_domain.add_constraint(fin_interior, "finInterior")
if cfg.custom.optimizeTfco2:
# Cooling Hole 2
# cooling inlet 2
coolingInlet2 = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.coolingInlet2,
outvar={"theta_fco2": nd_cooling_inlet_temp},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.inlet),
criteria=finInteriorCriteria2,
parameterization=geo.pr,
lambda_weighting= {"theta_fco2": 100},
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(coolingInlet2, "coolingInlet2")
# cooling outlet 2
coolingOutlet2 = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.coolingOutlet2,
outvar={"normal_gradient_theta_fco2": 0.0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.outlet),
lambda_weighting={"normal_gradient_theta_fco2": 1}, # weight zero on edges
criteria=finInteriorCriteria2,
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(coolingOutlet2, "coolingOutlet2")
# Cooling inlet walls insulating 2
coolingInletWall2 = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.finInteriorCriteriaGeo2,
outvar={"normal_gradient_theta_fco2": 0.0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.solidWall/2),
criteria=And(StrictLessThan(y, geo.nd_channel_origin[1]), StrictGreaterThan(y, geo.coolingInteriorBounds[1][0])),
lambda_weighting={"normal_gradient_theta_fco2": 1},
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(coolingInletWall2, "coolingInletWall2")
# Cooling Hole Interior 2
fin_interior2 = PointwiseInteriorConstraint(
nodes=thermal_nodes,
geometry=geo.finInterior2,
outvar={"advection_diffusion_theta_fco2": 0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.holeInteriorHR),
lambda_weighting={"advection_diffusion_theta_fco2": cfg.custom.adDifCo},
batch_per_epoch=cfg.batch_size.batchPerEpoch,
parameterization=geo.pr,
quasirandom=False
)
thermal_domain.add_constraint(fin_interior2, "finInterior2")
# --------------------------------------------------------------------Cooling Specific Thermal Contstraints--------------------------------------------------------------------
#-------------------------------------------------------------------- Channel Specific Constraints--------------------------------------------------------------------
if cfg.custom.optimizeTf:
# channel inlet
constraint_inlet = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.channelInlet,
outvar={"theta_f": nd_channel_inlet_temp},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.inlet),
lambda_weighting={"theta_f": 100}, # weight zero on edges
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(constraint_inlet, "inlet")
# channel outlet
constraint_outlet = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.channelOutlet,
outvar={"normal_gradient_theta_f": 0.0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.outlet),
lambda_weighting={"normal_gradient_theta_f": 1},
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(constraint_outlet, "outlet")
# flow interior low res upstream
lr_flow_interior = PointwiseInteriorConstraint(
nodes=thermal_nodes,
geometry=geo.channelInterior,
outvar={"advection_diffusion_theta_f": 0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.lr_interior_f*1/3),
criteria=And(LessThan(x, geo.solidInteriorBounds[0][0]), Not(geo.hrBoundsLarge)),
lambda_weighting={"advection_diffusion_theta_f": cfg.custom.adDifCh * 2 * cfg.custom.globalLambdaTf},
batch_per_epoch=cfg.batch_size.batchPerEpoch,
parameterization=geo.pr,
quasirandom=False
)
thermal_domain.add_constraint(lr_flow_interior, "lr_flow_interior")
# flow interior low res downstream
lr_flow_interior = PointwiseInteriorConstraint(
nodes=thermal_nodes,
geometry=geo.channelInterior,
outvar={"advection_diffusion_theta_f": 0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.lr_interior_f*2/3),
criteria=And(Not(geo.hrBoundsLarge), GreaterThan(x, geo.solidInteriorBounds[0][0])),
lambda_weighting={"advection_diffusion_theta_f": cfg.custom.adDifCh * 0.5 * cfg.custom.globalLambdaTf}, # @ All 270
batch_per_epoch=cfg.batch_size.batchPerEpoch,
parameterization=geo.pr,
quasirandom=False
)
thermal_domain.add_constraint(lr_flow_interior, "lr_flow_interior")
# flow interiror high res near three fin
hr_flow_interior = PointwiseInteriorConstraint(
nodes=thermal_nodes,
geometry=geo.channelInterior,
outvar={"advection_diffusion_theta_f": 0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.hr_interior_f),
criteria=geo.hrBoundsLarge,
lambda_weighting={"advection_diffusion_theta_f": cfg.custom.adDifCh * cfg.custom.globalLambdaTs}, # @ All 270
batch_per_epoch=cfg.batch_size.batchPerEpoch,
parameterization=geo.pr,
quasirandom=False
)
thermal_domain.add_constraint(hr_flow_interior, "hr_flow_interior")
# channel walls insulating
channel_walls = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.channelExternalWall,
outvar={"normal_gradient_theta_f": 0.0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.channelWall),
lambda_weighting={"normal_gradient_theta_f": 1},
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(channel_walls, "channel_walls")
#-------------------------------------------------------------------- Channel Specific Constraints--------------------------------------------------------------------
# --------------------------------------------------------------------Solid Specifc Thermal Constraints--------------------------------------------------------------------
if cfg.custom.optimizeTs:
# solid interior
solid_interior = PointwiseInteriorConstraint(
nodes=thermal_nodes,
geometry=geo.solidInterior,
outvar={"diffusion_theta_s": 0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.interiorSolid/4),
criteria=solidCriteria,
lambda_weighting={"diffusion_theta_s": cfg.custom.solidDiff * cfg.custom.globalLambdaTs,
},
batch_per_epoch=cfg.batch_size.batchPerEpoch,
parameterization=geo.pr,
quasirandom=False
)
thermal_domain.add_constraint(solid_interior, "solid_interior")
solid_interiorH1 = PointwiseInteriorConstraint(
nodes=thermal_nodes,
geometry=geo.finExterior1,
outvar={"diffusion_theta_s": 0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.interiorSolid*3/8),
criteria=And(Not(geo.solidExteriorCriteriaXZ), And(StrictGreaterThan(y,geo.solidInteriorBounds[1][0]), StrictLessThan(y,geo.solidInteriorBounds[1][1]))),
lambda_weighting={"diffusion_theta_s": cfg.custom.solidDiff * 1.5 * cfg.custom.globalLambdaTs},
# lambda_weighting={"diffusion_theta_s": (500 + 500*tanh(100 * Symbol("sdf"))) * cfg.custom.globalLambdaTs},
batch_per_epoch=cfg.batch_size.batchPerEpoch,
parameterization=geo.pr,
quasirandom=False
)
thermal_domain.add_constraint(solid_interiorH1, "solid_interiorH1")
solid_interiorH2 = PointwiseInteriorConstraint(
nodes=thermal_nodes,
geometry=geo.finExterior2,
outvar={"diffusion_theta_s": 0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.interiorSolid*3/8),
criteria=And(Not(geo.solidExteriorCriteriaXZ), And(StrictGreaterThan(y,geo.solidInteriorBounds[1][0]), StrictLessThan(y,geo.solidInteriorBounds[1][1]))),
lambda_weighting={"diffusion_theta_s": cfg.custom.solidDiff * 1.5 * cfg.custom.globalLambdaTs},
# lambda_weighting={"diffusion_theta_s": (500 + 500*tanh(100 * Symbol("sdf"))) * cfg.custom.globalLambdaTs},
batch_per_epoch=cfg.batch_size.batchPerEpoch,
parameterization=geo.pr,
quasirandom=False
)
thermal_domain.add_constraint(solid_interiorH2, "solid_interiorH2")
# Solid Exterior walls insulating
solid_walls = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.solidExteriorWall,
outvar={"normal_gradient_theta_s": 0.0},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.solidWall),
criteria=solidExteriorWallCriteria,
lambda_weighting={"normal_gradient_theta_s": 1 * cfg.custom.globalLambdaTs},
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(solid_walls, "solid_walls")
if cfg.custom.useHTC:
# # Solid Ambient Interface
fluid_solid_interface = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.channelSolidInterface,
outvar={
"diffusion_interface_HTC_theta_s": 0,
"theta_s": 0.95,
},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.channelInterface),
lambda_weighting={"diffusion_interface_HTC_theta_s": 0.01 * cfg.custom.globalLambdaTs,
"theta_s": 1 * cfg.custom.globalLambdaTs},
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(fluid_solid_interface, "fluid_solid_interface")
# --------------------------------------------------------------------Solid Specifc Thermal Constraints--------------------------------------------------------------------
# --------------------------------------------------------------------Mixed Constraints--------------------------------------------------------------------
if not cfg.custom.useHTC and (cfg.custom.optimizeTf or cfg.custom.optimizeTs):
# Solid Channel Interface
fluid_solid_interface = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.channelSolidInterface,
outvar={
"diffusion_interface_dirichlet_theta_f_theta_s": 0,
"diffusion_interface_neumann_theta_f_theta_s": 0,
# "theta_f": nd_channel_inlet_temp*0.8
},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.channelInterface),
lambda_weighting={"diffusion_interface_dirichlet_theta_f_theta_s": cfg.custom.dirichletInterfaceCh * cfg.custom.globalLambdaTs,
"diffusion_interface_neumann_theta_f_theta_s": cfg.custom.neumanInterfaceCh * cfg.custom.globalLambdaTs,
# "theta_f": 10,
},
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(fluid_solid_interface, "fluid_solid_interface")
if cfg.custom.optimizeTfco1 or cfg.custom.optimizeTfco2 or cfg.custom.optimizeTs:
# Solid Cooling Interface 1
fluid_solid_interface_co = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.finInteriorCriteriaGeo,
outvar={
"diffusion_interface_dirichlet_theta_fco_theta_s": 0,
"diffusion_interface_neumann_theta_fco_theta_s": 0,
# "theta_fco": nd_cooling_inlet_temp*1.2
},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.coolingInterface),
criteria=And(GreaterThan(y, geo.nd_channel_origin[1]), LessThan(y, geo.nd_channel_end[1])),
lambda_weighting={
"diffusion_interface_dirichlet_theta_fco_theta_s": cfg.custom.dirichletInterfaceCo * cfg.custom.globalLambdaTs,
"diffusion_interface_neumann_theta_fco_theta_s": cfg.custom.neumanInterfaceCo * cfg.custom.globalLambdaTs,
# "theta_fco": 10,
},
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(fluid_solid_interface_co, "fluid_solid_interface_co")
# Solid Cooling Interface 2
fluid_solid_interface_co2 = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.finInteriorCriteriaGeo2,
outvar={
"diffusion_interface_dirichlet_theta_fco2_theta_s": 0,
"diffusion_interface_neumann_theta_fco2_theta_s": 0,
# "theta_fco2": nd_cooling_inlet_temp*1.2
},
batch_size=int(cfg.batch_size.globalModifier*cfg.batch_size.coolingInterface),
criteria=And(GreaterThan(y, geo.nd_channel_origin[1]), LessThan(y, geo.nd_channel_end[1])),
lambda_weighting={
"diffusion_interface_dirichlet_theta_fco2_theta_s": cfg.custom.dirichletInterfaceCo * cfg.custom.globalLambdaTs,
"diffusion_interface_neumann_theta_fco2_theta_s": cfg.custom.neumanInterfaceCo * cfg.custom.globalLambdaTs,
# "theta_fco2": 10,
},
parameterization=geo.pr,
batch_per_epoch=cfg.batch_size.batchPerEpoch,
quasirandom=False
)
thermal_domain.add_constraint(fluid_solid_interface_co2, "fluid_solid_interface_co2")
# --------------------------------------------------------------------Mixed Constraints--------------------------------------------------------------------
# --------------------------------------------------------------------Validators--------------------------------------------------------------------
if cfg.run_mode == "train" or cfg.run_mode == "plot":
if cfg.run_mode == "plot":
# Dummy Constraint to Load Models
coolingInlet = PointwiseBoundaryConstraint(
nodes=thermal_nodes,
geometry=geo.coolingInlet,
outvar={"theta_fco": 0, "theta_fco2": 0, "theta_f": 0, "theta_s": 0, "u": 0, "u_co": 0, "u_co2": 0},
batch_size=1,
parameterization=geo.pr,
batch_per_epoch=1
)
thermal_domain.add_constraint(coolingInlet, "coolingInlet")
if not cfg.custom.useHTC and cfg.custom.optimizeTf:
# validator channel
ansysVarNames = ("Pressure [ Pa ]", "Temperature [ K ]", "Velocity u [ m s^-1 ]", "Velocity v [ m s^-1 ]", "Velocity w [ m s^-1 ]", "X [ m ]", "Y [ m ]", "Z [ m ]")
modulusVarNames = ("p_scaled", "theta_f_scaled", "u_scaled", "v_scaled", "w_scaled", "x", "y", "z")
scales = (1, 1, 1, 1, 1, length_scale_ch.magnitude, length_scale_ch.magnitude, length_scale_ch.magnitude)
for root, dirs, files in os.walk(to_absolute_path("./ansys/validators/channel")):
for name in files:
print(os.path.join(root, name))
file_path = str(os.path.join(root, name))
thermal_domain.add_validator(ansysValidator(file_path, ansysVarNames, modulusVarNames, thermal_nodes, scales, True, channelNonDim), name)
if cfg.custom.optimizeTs:
# validator solid
modif=1
ansysVarNames = ("Temperature [ K ]", "Temperature.Gradient X [ m^-1 K ]", "Temperature.Gradient Y [ m^-1 K ]", "Temperature.Gradient Z [ m^-1 K ]", "X [ m ]", "Y [ m ]", "Z [ m ]")
modulusVarNames = ("theta_s_scaled", "theta_s_scaled__x", "theta_s_scaled__y", "theta_s_scaled__z", "x", "y", "z")
scales = (1, 1, 1, 1, length_scale_ch.magnitude*modif, length_scale_ch.magnitude*modif, length_scale_ch.magnitude*modif)
for root, dirs, files in os.walk(to_absolute_path("./ansys/validators/solid")):
for name in files:
print(os.path.join(root, name))
file_path = str(os.path.join(root, name))
thermal_domain.add_validator(ansysValidator(file_path, ansysVarNames, modulusVarNames, thermal_nodes, scales, True, channelNonDim), name)
if cfg.custom.optimizeTfco1:
# validator cooling 1
ansysVarNames = ("Pressure [ Pa ]", "Temperature [ K ]", "Velocity u [ m s^-1 ]", "Velocity v [ m s^-1 ]", "Velocity w [ m s^-1 ]", "X [ m ]", "Y [ m ]", "Z [ m ]")
modulusVarNames = ("p_co_scaled", "theta_fco_scaled", "u_co_scaled", "v_co_scaled", "w_co_scaled", "x", "y", "z")
scales = (1, 1, 1, 1, 1, length_scale_ch.magnitude, length_scale_ch.magnitude, length_scale_ch.magnitude)
for root, dirs, files in os.walk(to_absolute_path("./ansys/validators/internal1")):
for name in files:
print(os.path.join(root, name))
file_path = str(os.path.join(root, name))
thermal_domain.add_validator(ansysValidator(file_path, ansysVarNames, modulusVarNames, thermal_nodes, scales, True, channelNonDim), name)
if cfg.custom.optimizeTfco2:
# validator cooling 2
ansysVarNames = ("Pressure [ Pa ]", "Temperature [ K ]", "Velocity u [ m s^-1 ]", "Velocity v [ m s^-1 ]", "Velocity w [ m s^-1 ]", "X [ m ]", "Y [ m ]", "Z [ m ]")
modulusVarNames = ("p_co2_scaled", "theta_fco2_scaled", "u_co2_scaled", "v_co2_scaled", "w_co2_scaled", "x", "y", "z")
scales = (1, 1, 1, 1, 1, length_scale_ch.magnitude, length_scale_ch.magnitude, length_scale_ch.magnitude)
for root, dirs, files in os.walk(to_absolute_path("./ansys/validators/internal2")):
for name in files:
print(os.path.join(root, name))
file_path = str(os.path.join(root, name))
thermal_domain.add_validator(ansysValidator(file_path, ansysVarNames, modulusVarNames, thermal_nodes, scales, True, channelNonDim), name)
# --------------------------------------------------------------------Validators--------------------------------------------------------------------
# # --------------------------------------------------------------------Inferencers--------------------------------------------------------------------
# outputChannelS = ["u_scaled", "v_scaled", "w_scaled", "p_scaled", "theta_f_scaled"]
# outputSolidS = ["theta_s_scaled"]
# outputCooling1S = ["x_st", "y", "z_st", "holeRadius1_s", "inletVelocity1_s", "holePosX1_s", "holePosZ1_s"] #["u_co_scaled", "v_co_scaled", "w_co_scaled", "p_co_scaled", "theta_fco_scaled"]
# outputCooling2S = ["x_st2", "y", "z_st2", "holeRadius2_s", "inletVelocity2_s", "holePosX2_s", "holePosZ2_s"] # ["u_co2_scaled", "v_co2_scaled", "w_co2_scaled", "p_co2_scaled", "theta_fco2_scaled"]
# outputsNS = []
# outputsS = []
# # max
# # paras = paramRanges_ch.maxval()
# # print(paras)
# paramRangs = {
# holeRadius1: ((5, 5),"mm"),
# holeRadius2: ((5, 5),"mm"),
# inletVelocity1: ((15, 15),"m/s"),
# inletVelocity2: ((15, 15),"m/s"),
# holePosX1: ((22, 22),"mm"),
# holePosX2: ((-22, -22),"mm"),
# holePosZ1: ((8, 8),"mm"),
# holePosZ2: ((-8, -8),"mm")}
# specificParas = parameterRangeContainer(paramRangs)
# specificParas.nondim(channelNonDim)
# paras=specificParas.minval()
# nrPoints = cfg.custom.inf_points
# if not cfg.custom.useHTC and cfg.custom.optimizeTf:
# outputsS += outputChannelS
# channelInteriorPoints = geo.inferencePlaneXZ.translate((0,0.0001,0)).sample_boundary(nrPoints*2, criteria=geo.channelInfCriteriaHR, parameterization=paras, quasirandom=False)
# # channelInteriorPointslr = geo.inferencePlaneXZ.translate((0,0.0002,0)).sample_boundary(int(nrPoints*1.5), criteria=geo.solidExteriorCriteriaXZ, parameterization=paras, quasirandom=False)
# inferenceChannelInterior = PointwiseInferencer(
# nodes=thermal_nodes,
# invar=channelInteriorPoints,
# output_names=outputsNS + outputsS
# )
# thermal_domain.add_inferencer(inferenceChannelInterior, "inferenceChannelInteriorMax")
# # inferenceChannelInteriorlr = PointwiseInferencer(
# # nodes=thermal_nodes,
# # invar=channelInteriorPointslr,
# # output_names=outputsNS + outputsS
# # )
# # thermal_domain.add_inferencer(inferenceChannelInteriorlr, "inferenceChannelInteriorLr")
# # if cfg.custom.optimizeTfco1:
# # outputsS += outputCooling1S
# # coolingInteriorPoints = geo.finInterior.sample_interior(nrPoints, parameterization=paras, quasirandom=False)
# # inferenceCoolingInterior = PointwiseInferencer(
# # nodes=thermal_nodes,
# # invar=coolingInteriorPoints,
# # output_names=outputsNS + outputsS
# # )
# # thermal_domain.add_inferencer(inferenceCoolingInterior, "inferenceCoolingInteriorMax")
# # if cfg.custom.optimizeTfco2:
# # outputsS += outputCooling2S
# # coolingInteriorPoints2 = geo.finInterior2.sample_interior(nrPoints, parameterization=paras, quasirandom=False)
# # inferenceCoolingInterior2 = PointwiseInferencer(
# # nodes=thermal_nodes,
# # invar=coolingInteriorPoints2,
# # output_names=outputsNS + outputsS
# # )
# # thermal_domain.add_inferencer(inferenceCoolingInterior2, "inferenceCoolingInteriorMax2")
# if cfg.custom.optimizeTs:
# outputsS += outputSolidS
# solidInteriorPoints = geo.inferencePlaneXZ.sample_boundary(int(nrPoints*1.5), criteria=solidInteriorCriteria, parameterization=paras, quasirandom=False)
# inferenceSolidInterior = PointwiseInferencer(
# nodes=thermal_nodes,
# invar=solidInteriorPoints,
# output_names=outputsNS + outputsS
# )
# thermal_domain.add_inferencer(inferenceSolidInterior, "inferenceSolidInteriorMax")
# #min
# # paras = paramRanges_ch.minval()
# paramRangs = {
# holeRadius1: (5,"mm"),
# holeRadius2: (5,"mm"),
# inletVelocity1: (19,"m/s"),
# inletVelocity2: (19,"m/s"),
# holePosX1: (20,"mm"),
# holePosX2: (-10,"mm"),
# holePosZ1: (-8,"mm"),
# holePosZ2: (-6,"mm")}
# specificParas = parameterRangeContainer(paramRangs)
# specificParas.nondim(channelNonDim)
# paras=specificParas.minval()
# if not cfg.custom.useHTC and cfg.custom.optimizeTf:
# outputsS += outputChannelS
# channelInteriorPoints = geo.inferencePlaneXZ.translate((0,0.00015,0)).sample_boundary(nrPoints*2, criteria=geo.channelInfCriteriaHR, parameterization=paras, quasirandom=False)
# inferenceChannelInteriorMin = PointwiseInferencer(
# nodes=thermal_nodes,
# invar=channelInteriorPoints,
# output_names=outputsNS + outputsS
# )
# thermal_domain.add_inferencer(inferenceChannelInteriorMin, "inferenceChannelInteriorMin")
# # if cfg.custom.optimizeTfco1:
# # outputsS += outputCooling1S
# # coolingInteriorPoints = geo.inferensePlaneYZ1.sample_boundary(nrPoints, parameterization=paras, quasirandom=False)
# # inferenceCoolingInteriorMin = PointwiseInferencer(
# # nodes=thermal_nodes,
# # invar=coolingInteriorPoints,
# # output_names=outputsNS + outputsS
# # )
# # thermal_domain.add_inferencer(inferenceCoolingInteriorMin, "inferenceCoolingInteriorMin")
# # if cfg.custom.optimizeTfco2:
# # outputsS += outputCooling2S
# # coolingInteriorPoints2 = geo.inferensePlaneYZ2.sample_boundary(nrPoints, parameterization=paras, quasirandom=False)
# # inferenceCoolingInterior2Min = PointwiseInferencer(
# # nodes=thermal_nodes,
# # invar=coolingInteriorPoints2,
# # output_names=outputsNS + outputsS
# # )
# # thermal_domain.add_inferencer(inferenceCoolingInterior2Min, "inferenceCoolingInterior2Min")
# if cfg.custom.optimizeTs:
# outputsS += outputSolidS
# solidInteriorPoints = geo.inferencePlaneXZ.sample_boundary(int(nrPoints*1.5), criteria=solidInteriorCriteria, parameterization=paras, quasirandom=False)
# inferenceSolidInteriorMin = PointwiseInferencer(
# nodes=thermal_nodes,
# invar=solidInteriorPoints,
# output_names=outputsNS + outputsS
# )
# thermal_domain.add_inferencer(inferenceSolidInteriorMin, "inferenceSolidInteriorMin")
# --------------------------------------------------------------------Inferencers--------------------------------------------------------------------
# --------------------------------------------------------------------For Design Optimization - Eval Validators, Inferences and Monitors--------------------------------------------------------------------
if cfg.run_mode == "eval":
# Dummy Constraint to Load Models