From 6cc57de668daf6f36bc63770a29a26b3a7b04f73 Mon Sep 17 00:00:00 2001 From: Mike Kryjak Date: Tue, 24 Mar 2026 11:54:12 +0000 Subject: [PATCH 01/11] Shorten timestep on 2D-production/recycling I checked that the tests are still sensitive. On my system they take ~35s each with the vast majority of the time taken by xBOUT loading. --- tests/integrated/2D-production/data/BOUT.inp | 2 +- tests/integrated/2D-production/runtest | 71 ++++++++++++-------- tests/integrated/2D-recycling/data/BOUT.inp | 2 +- tests/integrated/2D-recycling/runtest | 21 +++++- 4 files changed, 64 insertions(+), 32 deletions(-) diff --git a/tests/integrated/2D-production/data/BOUT.inp b/tests/integrated/2D-production/data/BOUT.inp index 484110c47..653921ec1 100644 --- a/tests/integrated/2D-production/data/BOUT.inp +++ b/tests/integrated/2D-production/data/BOUT.inp @@ -1,7 +1,7 @@ # Run one RHS nout = 1 -timestep = 0.1 +timestep = 0.0001 MZ = 1 NXPE = 1 diff --git a/tests/integrated/2D-production/runtest b/tests/integrated/2D-production/runtest index 945a455d5..d08f89bb3 100755 --- a/tests/integrated/2D-production/runtest +++ b/tests/integrated/2D-production/runtest @@ -8,6 +8,9 @@ import os from pathlib import Path import urllib.request import xhermes +from time import time + +t0 = time() gen_data = False verbose = False @@ -52,9 +55,15 @@ with urllib.request.urlopen(url, timeout=60) as response: with open(tmp_path, "wb") as out_file: shutil.copyfileobj(response, out_file) +t_download = time() +if verbose: + print(f"2D-Production test: download took {t_download-t0:.2f} seconds") + # Rename temp file with the correct name tmp_path.replace(zipfile_path) + + with zipfile.ZipFile(zipfile_path, "r") as zf: zip_contents = set(zf.namelist()) try: @@ -76,8 +85,9 @@ if file_hash != expected_hash: "2D-Production test: downloaded zip file hash does not match expected value" ) +t_extract = time() if verbose: - print("2D-Production test: downloaded and extracted files") + print(f"2D-Production test: zip extraction took {t_extract-t_download:.2f} seconds") ## Run test if not Path("hermes-3").is_file(): @@ -96,8 +106,9 @@ if s != 0: print(out) exit(1) +t_run = time() if verbose: - print("2D-Production test: completed simulation") + print(f"2D-Production test: simulation took {t_run-t_extract:.2f} seconds") # Load case ds = xhermes.open_hermesdataset( @@ -110,8 +121,9 @@ ds = xhermes.open_hermesdataset( ds = ds.hermes.extract_2d_tokamak_geometry() +t_load = time() if verbose: - print("2D-Production test: loaded results") + print(f"2D-Production test: loading results took {t_load - t_run:.2f} seconds") # Testing at specific locations around the domain @@ -137,44 +149,44 @@ regions["sol_ring"] = ds.isel(x=m["ixseps1"], theta=slice(None)) expected = {} expected["inner_lower_target"] = {} -expected["inner_lower_target"]["ddt(Pe)"] = [49328154.35291937, -742857787.9244659, -4304846309.626511, -4269222935.8140163, -4228845440.3667846, -4201074119.9200583, -4183643148.1795034, -4175766572.2705064, -4179174638.311868, -4198044970.6191106, -4228429110.693975, -4273195780.7852707, -4351851050.579009, -4487099180.781585, -4719904712.214905, -5123291049.449303, -5776929759.119654, -6641322387.879063, -2044928772.3309743, -1752159600.330765] -expected["inner_lower_target"]["ddt(NVd+)"] = [24805414.98816556, 24790612.81199426, -97627.2635343893, -97596.12913337455, -96747.44235314295, -96058.22161577165, -95580.76118844897, -95337.44120190071, -95409.47131803771, -95933.64243744679, -96904.02724128682, -98483.10299428772, -101188.61120696393, -105856.31959328105, -113930.88814205553, -127806.82641650974, -149513.4974881813, -176445.13347978715, 11961524.488574803, 11977289.041724209] -expected["inner_lower_target"]["ddt(Pd)"] = [21828111066.330017, 22082326767.775352, 17606286.852179475, 17289350.214005332, 17134245.630618777, 17010421.420951795, 16924801.329944693, 16881344.685646854, 16894478.226614676, 16988513.445242826, 17161335.257310737, 17438808.279930588, 17916050.809167895, 18745201.791681733, 20185956.322943345, 22669077.62679358, 26565374.63461685, 31545560.47500133, 10887351860.756546, 10872252148.845058] +expected["inner_lower_target"]["ddt(Pe)"] = [-701961858.3929809, -1499179783.3281152, -8849462223.88488, -8831051488.549446, -8753984989.447958, -8691651051.890438, -8648458002.247812, -8626430667.731749, -8632920959.625614, -8680321583.759829, -8768088551.261625, -8910898239.90236, -9155532468.54299, -9577380530.673615, -10306375902.070807, -11556904030.756124, -13506109862.898067, -15915303326.324772, -2424308738.890255, -2128859939.530964] +expected["inner_lower_target"]["ddt(NVd+)"] = [24930105.423950158, 24919065.960481595, -98778.13652086735, -98741.6946791423, -97872.80930592745, -97167.63081640242, -96679.2573085041, -96430.41335521628, -96504.07955420233, -97040.17129483374, -98032.75589236667, -99648.3845251484, -102417.9100220749, -107200.12878450433, -115484.96486891803, -129758.4815239607, -152179.87954933156, -180158.5386572483, 12052051.252591485, 12055161.688273467] +expected["inner_lower_target"]["ddt(Pd)"] = [15014205976.698784, 15258205159.219002, 9146362.327422312, 8953437.748600213, 8874293.65374496, 8810078.63725109, 8765619.543826174, 8742981.126763903, 8749713.236555804, 8798549.864154402, 8887870.312733471, 9029521.738910213, 9274148.969614554, 9701892.519143388, 10447952.419195276, 11736975.010078121, 13764025.118308637, 16316056.430827195, 7597415509.685901, 7589490855.171624] expected["inner_upper_target"] = {} -expected["inner_upper_target"]["ddt(Pe)"] = [51380215.46570025, -738544103.2371651, -4295914854.21501, -4255026670.6730967, -4210644212.348379, -4180242170.2672133, -4161382201.668547, -4153043578.415418, -4156883279.821161, -4176978617.6762223, -4209222384.3128138, -4256596646.938353, -4338916649.520999, -4479555178.378897, -4721237937.717243, -5136600369.062243, -5806753645.000433, -6692265090.053569, -2074322697.9551363, -1778872010.4077199] -expected["inner_upper_target"]["ddt(NVd+)"] = [24774710.16813547, 24767340.126524083, 97345.53720389033, 97141.49196217558, 96166.95441848449, 95393.85174214603, 94870.0815389171, 94610.99439852523, 94695.24700444464, 95256.38155746712, 96284.1458087195, 97945.16450483247, 100767.65236768182, 105610.20942114433, 113976.14072172214, 128239.66267394855, 150445.4350018012, 177963.93263920944, 11964025.33231473, 11954446.701616704] -expected["inner_upper_target"]["ddt(Pd)"] = [21799586807.619343, 22051597598.11019, 17552843.24560799, 17208491.017438278, 17031143.683440074, 16892421.947342232, 16798587.3341891, 16752344.717857098, 16767664.122598259, 16868277.04199685, 17051320.836964116, 17343446.014512632, 17841597.782523453, 18701977.851769567, 20194795.529129494, 22747453.33114883, 26733912.154986855, 31819866.282596696, 10867344488.807095, 10852354448.255121] +expected["inner_upper_target"]["ddt(Pe)"] = [-699040647.2694988, -1493982615.7431939, -8823943202.47202, -8789962558.824818, -8701462180.468233, -8631501884.342407, -8584096490.494626, -8560632815.489453, -8568230476.558625, -8618987809.323042, -8711967060.982983, -8862219398.87059, -9117470243.350624, -9555162105.26555, -10310499744.83234, -11595894771.356598, -13589521540.56696, -16050099401.450678, -2453377393.0964217, -2155218433.685715] +expected["inner_upper_target"]["ddt(NVd+)"] = [24897496.78635522, 24886512.005943004, 98491.93446997949, 98278.29513137124, 97280.76266255787, 96489.8861081698, 95954.22466234666, 95689.2920339197, 95775.43919427939, 96349.24642880238, 97400.37873759655, 99099.64444049557, 101988.63531253753, 106949.66414838922, 115533.3311221996, 130206.48717574387, 153147.28547105496, 181744.18707505654, 12028720.38263661, 12031833.247237517] +expected["inner_upper_target"]["ddt(Pd)"] = [14994972649.332018, 15236827218.079597, 9118155.256683575, 8911160.373716276, 8820314.935151355, 8748306.937132085, 8699548.710075507, 8675448.084100712, 8683314.865534816, 8735578.88173725, 8830237.124684855, 8979565.178662885, 9235121.321032396, 9679133.439105643, 10452293.114633715, 11777512.500410842, 13851591.682986833, 16459518.70842988, 7584177368.827867, 7576331873.909826] expected["outer_upper_target"] = {} -expected["outer_upper_target"]["ddt(Pe)"] = [-7890335377.73377, -7707693891.382022, -9414608059.012512, -9284363796.595522, -9202231145.391302, -9128264945.939098, -9060468529.554802, -8998000728.168736, -8940125118.531174, -8885969475.426334, -8831533249.729504, -8764598675.345488, -8669117224.529337, -8539862765.8707285, -8395885626.150305, -8293946052.599526, -8330740510.793875, -8556598545.020531, -3257350411.2690067, -3576323325.3890123] -expected["outer_upper_target"]["ddt(NVd+)"] = [26915904.45608957, 26906149.970863506, -262269.3425409349, -259561.4350016547, -257047.7442161865, -254749.4813175653, -252631.6417524996, -250670.26702716106, -248850.28791518227, -247153.49285188207, -245458.87737383114, -243392.01180419794, -240464.1673293826, -236518.52822198943, -232158.5367624449, -229194.8637367968, -230691.24020097498, -238323.44609970614, 12400075.100999925, 12413814.585688079] -expected["outer_upper_target"]["ddt(Pd)"] = [23731762836.44862, 24010957843.043068, 47973601.83764425, 46542728.897757016, 46043384.71266811, 45621166.99457978, 45232175.15578086, 44871893.50904679, 44537578.66713123, 44225866.85165873, 43906776.685091354, 43497959.25529896, 42937539.16958144, 42203539.93633203, 41402201.60134631, 40859725.4942246, 41129534.49361283, 42779623.3203177, 11271509812.238415, 11253819154.157906] +expected["outer_upper_target"]["ddt(Pe)"] = [-8789078657.054876, -8607487809.407537, -23404631798.06935, -23137193767.44033, -22923179006.227013, -22727204584.171326, -22546433346.453415, -22378877181.75347, -22223252346.68647, -22078008047.831448, -21932747513.197884, -21755225656.335003, -21503129658.745857, -21162306428.565918, -20783966457.001328, -20524064179.522243, -20647913060.552975, -21300873226.238827, -3666199407.1905165, -3986777134.0843253] +expected["outer_upper_target"]["ddt(NVd+)"] = [27134794.02205901, 27133755.164844077, -270587.26283424057, -267654.541184525, -264982.8748315516, -262541.6545805871, -260293.2730227858, -258212.00558490504, -256281.63738355093, -254482.6700133599, -252686.72227618776, -250497.22032824415, -247397.45100650765, -243223.44476478483, -238615.5202110081, -235485.60084327328, -237063.90635116014, -245128.16869089202, 12512036.714121189, 12508839.23023494] +expected["outer_upper_target"]["ddt(Pd)"] = [16372641730.522472, 16626529893.537407, 25069506.380063523, 24303219.10077882, 24059044.550968695, 23835946.86831967, 23630485.45543071, 23440307.295676913, 23263928.078312278, 23099564.63759126, 22927387.415258802, 22697017.872459196, 22389646.36438664, 21996572.71869353, 21571316.86335293, 21283445.529979847, 21423114.968473796, 22175127.401863053, 7864274744.750637, 7859210016.619551] expected["outer_lower_target"] = {} -expected["outer_lower_target"]["ddt(Pe)"] = [-7696199821.469994, -7517796150.96834, -9272982863.12281, -9148985623.188478, -9067887026.480276, -8995590048.035276, -8929649082.37819, -8868792359.798933, -8811686883.954374, -8756197446.947426, -8700181489.082815, -8632836719.992008, -8539020398.231585, -8415045806.139964, -8282091451.990448, -8202357544.375875, -8275778883.304087, -8543412003.201659, -3247671298.173232, -3589758254.9884562] -expected["outer_lower_target"]["ddt(NVd+)"] = [26882639.805602062, 26889663.670910127, 257814.496590185, 255175.31768802743, 252721.62836756857, 250468.72819034144, 248391.19602840624, 246473.72228003322, 244685.79306965988, 242960.77223522274, 241230.90282888012, 239160.26463793195, 236282.02485446676, 232492.03290159634, 228476.79363697572, 226227.50402382467, 228918.0986389047, 237996.9116694144, 12324881.569351751, 12304738.681036424] -expected["outer_lower_target"]["ddt(Pd)"] = [23699507701.410305, 23975597448.119095, 47133495.63720295, 45742550.63497015, 45257371.53802125, 44843584.94173264, 44462079.17042496, 44109957.67007632, 43781666.86494018, 43465120.99762449, 43140212.65354516, 42732080.37516105, 42182028.253271654, 41477426.09698772, 40739649.55083099, 40327513.93196058, 40814122.580714636, 42719029.84354287, 11178124132.089209, 11160973205.729183] +expected["outer_lower_target"]["ddt(Pe)"] = [-8590774321.206867, -8413448847.482278, -23023636859.765823, -22762414988.433784, -22552922729.981384, -22360407781.89368, -22182715047.34058, -22018546055.155735, -21865280266.065907, -21717135679.161137, -21568352970.922516, -21389971539.477703, -21141440412.13172, -20813185082.50465, -20463748473.246456, -20265071996.760475, -20492303272.269432, -21270149563.758247, -3653049924.7682524, -3996985741.3515477] +expected["outer_lower_target"]["ddt(NVd+)"] = [27098245.334460255, 27097203.24101261, 265848.7376228907, 262993.30363926815, 260388.13857312407, 257997.5625475745, 255794.2166940457, 253761.58908917048, 251867.11848241117, 250040.054005325, 248208.5951704684, 246017.33029848168, 242973.17640620537, 238967.84788367205, 234728.27653112903, 232354.6134366621, 235192.0088846579, 244782.71419614818, 12401967.270713395, 12398497.333215147] +expected["outer_lower_target"]["ddt(Pd)"] = [16348617559.117064, 16599742624.778463, 24623794.360936105, 23878010.145980082, 23639959.190310214, 23421532.86883631, 23220226.501549855, 23034527.89361795, 22861461.792449873, 22694571.065650567, 22519464.03739986, 22290014.549381863, 21988599.595274065, 21611326.215515602, 21219680.516759127, 21000344.294578698, 21253905.216931745, 22143468.831178702, 7800783296.665585, 7795908855.181367] expected["outer_midplane_a"] = {} -expected["outer_midplane_a"]["ddt(Pe)"] = [575756628520.4132, 575755524091.3022, 2597004.6356121176, -113.83636558070454, -116.55504691608044, -116.35877338204561, -116.24786240402193, -116.15386804592688, -116.05963556265415, -115.96203358535988, -115.96351170304325, -116.01851366920113, -116.05238456220722, -116.07419641941786, -116.16458989795116, -117.60652064190197, -178.78175677232554, -3921368.251137794, 6459454940.276916, 118042455815.39447] -expected["outer_midplane_a"]["ddt(NVd+)"] = [-30154037.158708256, -30154026.85725996, 7.522570297136237e-10, -7.361463823883828e-09, -5.388944448939895e-09, -4.102384031746388e-09, -3.638055003158399e-09, -3.4561116355151163e-09, -3.2906614067296837e-09, -3.0821821061234957e-09, -3.1993587673177264e-09, -3.5477407763855757e-09, -3.95555308891562e-09, -4.534718114994734e-09, -5.803652631636331e-09, -1.3346474693247918e-08, -6.045983402760881e-08, 0.0013857043388078823, 18170290.21809738, 6961358.424329617] -expected["outer_midplane_a"]["ddt(Pd)"] = [5292523629714.188, 5292533460171.823, 451.9136805350977, 451.71627167219646, 451.4688427096021, 451.3547026433745, 451.28842241882256, 451.25271170273373, 451.23532019155493, 451.2260373873967, 451.21934724363126, 451.2114794306884, 451.1989278311948, 451.16877307480826, 450.9081112377629, 444.77762580630383, 356.99511638429976, 69781.7778858502, 59985354149.75475, 1085591880839.2262] +expected["outer_midplane_a"]["ddt(Pe)"] = [11334148330.76789, 11339115787.183214, 2597007.0953292064, -116.85701867093881, -116.7954446943411, -116.76650568244983, -116.74901391282451, -116.73961111640538, -116.73516959560204, -116.73281146047266, -116.73123583333035, -116.72938895439181, -116.72644474856148, -116.72174378294572, -116.71324882279168, -116.69715025275985, -116.73011219751741, -3921049.789799078, 5883759391.612391, 7375051404.729079] +expected["outer_midplane_a"]["ddt(NVd+)"] = [27411639.137971215, 27411010.185869757, 2.6992534364870042e-18, -3.610414591271963e-12, -3.1075429659090278e-12, -3.795448520946963e-12, -3.18942306493015e-12, -3.1988862106514207e-12, -3.2015546508800496e-12, -3.2020293072139276e-12, -3.841930295861274e-12, -3.840529329431264e-12, -3.837461369408508e-12, -3.83039633854506e-12, -6.357833046136906e-12, -6.303257607375951e-12, -1.057203645504073e-11, 1.386011930097718e-06, 18230855.281411886, 17899620.494429544] +expected["outer_midplane_a"]["ddt(Pd)"] = [104817010368.3209, 104862667530.35992, 453.46419892649334, 453.265467039755, 453.0143813193228, 452.90058491335833, 452.83363677954753, 452.7971853131224, 452.7799642835784, 452.77081962798945, 452.7642718360932, 452.75667119841034, 452.7452496196667, 452.72701094106804, 452.6957748604165, 452.63327970182706, 452.6243535084463, 59504.39222505075, 54694028375.319695, 68428251856.9325] expected["sol_boundary"] = {} -expected["sol_boundary"]["ddt(Pe)"] = [7044211750.017663, 14140509196.6377, -6641322387.879063, -1281967550.207726, -1180160788.7209682, -1029753203.5013249, -785668874.7426388, -79811700.60719119, -3537119.0923077855, -2456960.079428063, -2829345.7504795194, -2918098.277202271, -2918098.144927386, -2829348.7749785907, -2458484.075182945, -3598846.16738496, -81810651.82344545, -799748405.9796479, -1041521849.2098027, -1188469987.692734, -1287603750.3850515, -6692265090.053569, 13342819449.19605, 6997035032.427317, 7014955985.370645, 17445286859.549217, -8556598545.020531, -1310902275.080272, -1259372808.246334, -1190231544.4902985, -1095533701.0548673, -968127318.7281018, -799496333.3571177, -599966541.4738841, -416996893.5707662, -237513844.58380046, -38094520.53461265, -2988859.0163759654, -2648643.607936476, -3528366.6216462445, -3921368.251137794, -3921376.9525574795, -3528616.352071107, -2655154.8413644014, -3138092.8759173932, -41082101.730031766, -252233462.1339021, -434724390.5685763, -616199758.957929, -811683382.5175146, -976893650.7526073, -1098297033.5492222, -1198721109.6873155, -1250089942.1124496, -1320679204.2415128, -8543412003.201659, 15900801822.099977, 6967223040.768236] -expected["sol_boundary"]["ddt(NVd+)"] = [28391537.017052945, 30096250.760985907, -176445.13347978715, -141.09493632854887, -7.780167950546939, -6.4413061895529315, -3.9050382665163363, -0.5211468307467736, -0.01694590261224284, 0.0014373715961704607, 0.0008859779472811278, 0.00016811153477946423, -0.00016811281082783003, -0.0008856761452770769, -0.001423603235233547, 0.017546282043943096, 0.5359330711979584, 4.016376821582494, 6.54459627587584, 7.911795265201734, 144.28478774812535, 177963.93263920944, 26816560.066757064, 27975780.80139235, 28575196.574150953, 30086325.231459443, -238323.44609970614, -293.9975278408383, -11.649187145779072, -9.724990023813424, -8.013560301985718, -6.279941717033772, -4.3990749532300795, -2.6678967015466686, -1.7921980352898292, -0.8237549332746127, -0.14884609685486008, -0.006551866362132482, 0.0049402540607762935, 0.004299893467438716, 0.0013857043388078823, -0.0013856507347503816, -0.004298080186403646, -0.0048980290689500045, 0.007491519561981747, 0.16151270304397544, 0.8850319958653758, 1.890437597346653, 2.761496791531058, 4.500134627756295, 6.370995623121479, 8.088831798845845, 9.780527422987136, 11.666528113375634, 295.5382928748633, 237996.9116694144, 26697735.47937563, 27797294.549335007] -expected["sol_boundary"]["ddt(Pd)"] = [65386420857.94411, 140379997789.28366, 31545560.47500133, 43903.445869522046, 22033.408849861396, 19670.942670924334, 21236.965182285767, 21284.14495430035, 29017.859823348674, 43389.29274478825, 50615.83053844198, 52172.57083011889, 52172.57082993825, 50615.83053871363, 43389.29274641467, 29017.86000044367, 21284.057757114915, 21224.777534672794, 19646.632554888107, 21981.288239481746, 44368.02333835476, 31819866.282596696, 140368126683.4227, 64956497579.30043, 65118687394.22316, 139680817855.10947, 42779623.3203177, 52334.31386843403, 26907.508517636652, 25683.929106064847, 24561.094155774354, 23489.18297510841, 21756.27571997549, 19069.081405613048, 18027.485864809045, 19238.631155054532, 19117.05871194449, 35003.409002281536, 55414.43732667743, 71802.55037946928, 69781.7778858502, 69781.77788573955, 71802.55037974098, 55414.437332451336, 35003.40899610905, 19116.8847771998, 19224.447287839354, 17992.17240993671, 18997.136908905555, 21613.505842663537, 23269.639014753444, 24273.906954092596, 25331.193082362486, 26492.67466324959, 52226.25546926917, 42719029.84354287, 139682017303.9314, 64683464529.427864] +expected["sol_boundary"]["ddt(Pe)"] = [9147662242.455286, 13413349867.111698, -15915303326.324772, -235004386.52630776, -2573359.417000814, -1080769.5432358312, -1160274.5074505645, -1169357.893068723, -1605960.9965739148, -2418089.977143572, -2828866.790314278, -2917258.6331448057, -2917258.633134451, -2828866.7903316407, -2418089.9771426367, -1605961.000760319, -1169357.870510763, -1159503.5861332845, -1079816.5590735574, -2652835.4499015827, -242161513.28153047, -16050099401.450678, 12607438475.357086, 9148155343.592468, 9120689032.567234, 16784919055.85318, -21300873226.238827, -727748830.3001844, -19488176.829850353, -1686865.3067635575, -1355938.0073427209, -1293342.7138832766, -1195775.7262589014, -1044754.9939097713, -984816.8616117283, -1051878.9814284493, -1047056.7567408985, -1436305.9698601882, -2592335.3721857346, -3526547.029351511, -3921049.789799078, -3921049.7897891193, -3526547.0293668155, -2592335.3721706825, -1436305.9697091824, -1047056.6968764504, -1051033.1578108056, -982797.697528408, -1040701.940399521, -1187733.2773297138, -1280968.5147299608, -1339991.8048691915, -1686713.8485614809, -20070876.73981682, -733201604.2318095, -21270149563.758247, 15219091570.296011, 9123398972.167463] +expected["sol_boundary"]["ddt(NVd+)"] = [27965758.25489674, 29921403.525794048, -180158.5386572483, -0.25678617942429444, -0.00099210409754064, -4.730562770331288e-06, 8.201740934830418e-07, 9.071343171134917e-07, 1.5673919541158623e-06, 1.8075385890103469e-06, 8.912983712899969e-07, 1.6781590250093625e-07, -1.6781590256127795e-07, -8.912983716074666e-07, -1.807538589541688e-06, -1.5673917349744658e-06, -9.087030581108094e-07, -8.409599630718918e-07, 5.0119526728306216e-06, 0.0010377121754149231, 0.26274704018145206, 181744.18707505654, 27551402.35072559, 27965086.03970171, 27968825.53326345, 29985407.686952073, -245128.16869089202, -0.5579039030205757, -0.006801708347879607, -0.00011294478540997627, -4.426478006706961e-06, -3.51149723291996e-06, -4.1834992420089365e-06, -2.789998289367938e-06, 9.286804680494488e-08, 5.243480446088509e-07, 1.293417682170279e-06, 3.089026944996127e-06, 5.325450464967266e-06, 4.310220087640809e-06, 1.386011930097718e-06, -1.3860119307688146e-06, -4.310220089556725e-06, -5.325450466626116e-06, -3.0890272941982084e-06, -1.2962608521074998e-06, -5.482091823302218e-07, -1.37832989304325e-07, 2.780265264444143e-06, 4.141854889773126e-06, 3.404530834308758e-06, 4.382294851948851e-06, 0.00011876924073506516, 0.006958348608064335, 0.5609368596638125, 244782.71419614818, 27489923.713890273, 27967346.606751617] +expected["sol_boundary"]["ddt(Pd)"] = [84720627541.73021, 96394009954.48932, 16316056.430827195, 21167.94216123154, 18681.83487842866, 16683.89164464725, 18039.02195128105, 18053.13776185012, 24611.808523026742, 36869.25092966416, 43061.35535722714, 44388.440296405955, 44388.44029624992, 43061.35535746125, 36869.25092967708, 24611.808523346168, 18053.051358399396, 18029.121045960066, 16663.34235631647, 18637.633071300974, 21093.002229460708, 16459518.70842988, 96393496590.6429, 84725166486.57939, 84472712462.0566, 96289414131.26791, 22175127.401863053, 23919.878677851637, 22832.292622289282, 21795.015479328762, 20840.938423331074, 19931.234684259114, 18458.65729775797, 16175.701158480531, 15299.952784999443, 16333.711180658913, 16222.741743923862, 29991.14782618698, 47424.91238805747, 61500.55355367606, 59504.39222505075, 59504.39222495491, 61500.553553907375, 47424.91238794103, 29991.14782577931, 16222.554830613079, 16321.883642221796, 15270.150245949651, 16114.756381368254, 18337.532127800674, 19744.767699159085, 20596.91620828044, 21495.159752840038, 22479.439154042615, 23523.0810865654, 22143468.831178702, 96288009105.78864, 84497625848.94241] expected["core_and_pfr_boundary"] = {} -expected["core_and_pfr_boundary"]["ddt(Pe)"] = [4420734387.749138, 3780415237.7203994, 49328154.35291937, 4420734387.749138, 42184488397.26909, 73348084589.0518, 117361784406.9702, 575730061546.6586, 575773277254.1138, 575755894109.8029, 575753872955.2098, 575757285484.1746, 575757285484.1672, 575753872955.227, 575755894109.7498, 575773277254.1985, 575730061546.4044, 117610645215.03716, 73959410359.09547, 42699506521.341576, 4407357141.287916, 51380215.46570025, 3774414507.3599057, 4407357141.287916, 4581132534.030985, 4145093458.273619, -7890335377.73377, 4581132534.030985, 16901586940.596972, 17332571676.214497, 17883416710.890488, 18645547980.29455, 20285043861.946148, 26726703373.048866, 57403590824.96284, 116569469663.7117, 575738667298.5244, 575768927520.3156, 575760586008.4976, 575753172083.3536, 575756628520.4132, 575756628520.4082, 575753172083.3507, 575760586008.4998, 575768927520.3739, 575738667298.2947, 116638589077.28876, 58284742669.73684, 27249214657.554077, 20587084986.253586, 18862325491.588097, 18057373721.223213, 17474952361.378998, 17017961104.052933, 4559171667.031011, -7696199821.469994, 4138095444.3909025, 4559171667.031011] -expected["core_and_pfr_boundary"]["ddt(NVd+)"] = [24623580.75300861, 26466850.248002786, 24805414.98816556, 24623580.753009662, 19761252.89488105, 15250756.556122424, 9544940.836018689, -30150625.9319029, -30155562.181406092, -30154139.09416781, -30153797.07206407, -30154101.23977953, -30154139.63804719, -30153726.71043466, -30153807.87589932, -30156035.605545163, -30151896.053211574, 9517861.120010078, 15169530.203094827, 19673828.752294105, 23904311.431828376, 24774710.16813547, 23861106.78796484, 23904311.431829408, 27531211.418668717, 28392969.285780605, 26915904.45608957, 27531211.418674957, 25483244.455812488, 25314953.051089752, 25097356.9059675, 24775032.2512371, 24151190.09499245, 22474017.312566303, 17319613.463678654, 9435737.177958583, -30151551.4961276, -30155100.4219222, -30154611.941816162, -30153756.550579727, -30154037.158708256, -30154065.21453069, -30153619.243606396, -30154320.677031297, -30155583.85025595, -30152779.402254973, 9427101.78841773, 17197549.096693136, 22366749.79939472, 24066829.96344414, 24705815.764741722, 25036681.78227659, 25260491.05311693, 25425136.437040903, 26123094.908793855, 26882639.805602062, 25593174.537251864, 26123094.90879961] -expected["core_and_pfr_boundary"]["ddt(Pd)"] = [41272752003.954, 125050732591.7888, 21828111066.330017, 41273232570.603676, 388367914444.4472, 674798027490.3805, 1079335705969.9529, 5292279445290.253, 5292676649994.313, 5292516880601.116, 5292498303078.677, 5292529667918.367, 5292529668149.045, 5292498302678.192, 5292516878795.991, 5292676652567.323, 5292279451764.78, 1081623029670.034, 680416831443.9292, 393101550661.5498, 41156238197.54028, 21799586807.619343, 124895282154.60811, 41156707437.50535, 42749993573.4502, 134156875070.51855, 23731762836.44862, 42750081904.9533, 155987665493.4469, 159949430577.34927, 165012455494.25406, 172017354428.40836, 187086254400.45795, 246292687840.80948, 528249373731.1704, 1072053402691.3237, 5292358542570.524, 5292636671004.891, 5292560004404.531, 5292491861336.243, 5292523629714.188, 5292523629828.594, 5292491860766.348, 5292560003119.111, 5292636673221.031, 5292358548385.847, 1072688691246.9702, 536348196848.76483, 251095182955.2361, 189862369509.10895, 174009796902.72284, 166611335119.65848, 161258145655.50778, 157057630700.19327, 42555471259.541, 23699507701.410305, 133979968825.86827, 42555548570.89456] +expected["core_and_pfr_boundary"]["ddt(Pe)"] = [10317499253.792715, 3052751381.686176, -701961858.3929809, 10317499253.792715, 10364311448.25626, 8735081216.058596, 8427836102.578113, 12396331122.384851, 10610850906.449629, 11225406054.176552, 11456731408.13044, 11378986172.789959, 11378986172.86291, 11456731407.840809, 11225406054.810904, 10610850905.696518, 12396331125.789965, 8444031548.385278, 8727957909.234539, 10334589000.871397, 10300690255.700598, -699040647.2694988, 3047195296.697415, 10300690255.700598, 10892015689.977913, 3394615156.4450665, -8789078657.054876, 10892015689.977913, 10725852476.243692, 10700140647.657331, 10678286081.042614, 10670369394.715837, 10821410600.589443, 10696608960.293018, 8651984408.708393, 7904529946.635277, 12225275429.821358, 10754449387.487415, 11096871604.195526, 11378011876.899805, 11334148330.76789, 11334148330.862423, 11378011876.894005, 11096871604.332668, 10754449386.862438, 12225275433.29366, 7911139898.662424, 8640903385.380892, 10659618074.970716, 10793099876.752905, 10648862664.423758, 10659499765.527046, 10683000608.013853, 10709436740.798868, 10873064397.373762, -8590774321.206867, 3387809860.13607, 10873064397.373762] +expected["core_and_pfr_boundary"]["ddt(NVd+)"] = [23430424.266810276, 26227563.50381719, 24930105.423950158, 23430424.266810276, 22694806.124100246, 21510686.756697256, 20273845.02663172, 27277177.273134768, 27503205.83969638, 27425405.274345055, 27396120.927808132, 27405962.951019675, 27405962.950247444, 27396120.929248553, 27425405.280748367, 27503205.831032645, 27277177.245233074, 20269865.555419546, 21491780.27915913, 22665930.691696323, 23391341.579820633, 24897496.78635522, 24443657.807319615, 23391341.579820633, 25977000.939622384, 28310706.89293217, 27134794.02205901, 25977000.939622384, 25847915.822947, 25730747.290480673, 25570780.69045689, 25325235.24779192, 24845201.253212396, 23825219.778531116, 21992960.214609053, 20151377.46763845, 27298830.698194034, 27485026.551136922, 27441677.089022666, 27406086.289392646, 27411639.137971215, 27411639.13740282, 27406086.29211813, 27441677.094642974, 27485026.54215176, 27298830.671560574, 20148867.81822831, 21960626.94515083, 23775022.159419928, 24794819.70802652, 25280607.634110805, 25530123.22835253, 25693030.234543856, 25813235.89847062, 25858946.13211311, 27098245.334460255, 26378651.170295067, 25858946.13211311] +expected["core_and_pfr_boundary"]["ddt(Pd)"] = [95472765208.82193, 85249075572.42838, 15014205976.698784, 95472771976.08694, 95903068433.39738, 80928525858.09412, 78104581800.3928, 114579719850.02457, 98169056100.66707, 103817540914.37524, 105943693064.67294, 105229122886.905, 105229122887.58008, 105943693062.00288, 103817540920.1699, 98169056093.79373, 114579719881.46297, 78253437000.84007, 80863054288.07953, 95629884174.48868, 95318352871.66122, 14994972649.332018, 85137699539.74922, 95318359498.8185, 100753075681.76399, 92087003752.72913, 16372641730.522472, 100753087099.79814, 99226055822.93161, 98989733869.15402, 98788864690.72018, 98716101029.66226, 100104347407.17441, 98957273507.29204, 80164768437.60385, 73294782572.99144, 113007516793.38277, 99488895080.79713, 102636158102.04434, 105220167961.45195, 104817010368.3209, 104817010369.19208, 105220167961.38724, 102636158103.2797, 99488895075.09506, 113007516825.42247, 73355535808.52028, 80062920796.77023, 98617283752.57764, 99844138548.26767, 98518428876.11981, 98616196349.52806, 98832196740.03963, 99075175901.69656, 100579393779.96979, 16348617559.117064, 91947569239.03954, 100579403984.90804] expected["sol_ring"] = {} -expected["sol_ring"]["ddt(Pe)"] = [4947143998.102735, 10125142221.276571, -4228429110.693975, -1173761132.38761, -824950355.3844862, -137021880.04420388, -1030442.8290566485, -2783.53269446995, -159.70300412907392, -117.94959719347148, -116.12742129414215, -117.18088484204839, -117.1808848428057, -116.12755018985779, -117.95429180306064, -159.9294972235538, -2816.7492972584932, -1042260.8726485621, -137486710.20027688, -823684106.1047541, -1172365226.377254, -4209222384.3128138, 9782962872.233835, 4945222228.086791, 4418538362.543849, 18258044904.64439, -8831533249.729504, -1362494422.57246, -1313436276.3363388, -1229692763.6856513, -1106424205.8956504, -915757269.3991339, -634184179.1075665, -265096957.65714327, -16596505.01422686, -59267.576444183906, -213.03995266321363, -136.1281883814981, -117.25092617381276, -115.42232648266874, -115.96351170304325, -115.96351189665496, -115.42232648160798, -117.25107071606732, -136.12933688735117, -212.8314448649941, -59198.835966051854, -16451437.31505226, -261862787.08173594, -627908936.4926707, -909446950.4105513, -1101368589.2334886, -1226314190.7252827, -1310965910.5979605, -1362498786.8174813, -8700181489.082815, 16344305922.246658, 4421941602.026499] -expected["sol_ring"]["ddt(NVd+)"] = [28808709.13732992, 30111256.554943208, -96904.02724128682, -43.77715675050117, -4.506113972807182, -0.7669388119700169, -0.018845908740826634, -6.8711224433164e-05, -3.3926261422010875e-07, -9.343813675263272e-08, -1.6778974024570106e-08, -5.336682173368887e-10, 5.336682173413758e-10, 1.6779760604996454e-08, 9.347758771603427e-08, 3.438811944761622e-07, 6.948374473463507e-05, 0.018981162070019406, 0.767591495614513, 4.511397566493766, 43.796151147559385, 96284.1458087195, 26975973.44333189, 27983131.019404706, 29229621.58114216, 30094634.55470384, -245458.87737383114, -297.27501916457715, -11.760945481249697, -9.614545386432976, -7.544548923918993, -5.307277158138101, -2.9590349521958976, -0.9782289433645092, -0.10215521305736111, -0.0012136403762718544, -2.839783621431561e-06, 3.110329405184423e-08, -9.388272439406171e-08, -2.2507833985761243e-08, -3.1993587673177264e-09, 3.199358769409155e-09, 2.2507834051464807e-08, 9.388368072206824e-08, -3.1340291417632385e-08, 2.8293109879953593e-06, 0.0012058536137763039, 0.10087531701566593, 0.9642817406957138, 2.917252526076318, 5.244639095883621, 7.47324264539343, 9.526490884297127, 11.61416791099522, 288.11600756337907, 241230.90282888012, 26682042.500551146, 27676143.577819854] -expected["sol_ring"]["ddt(Pd)"] = [46111337492.32634, 141214517945.7954, 17161335.257310737, 6230.126634873802, 497.1393789700653, 547.6170771675216, 436.2056017396185, 411.2169319012892, 521.4013136820438, 466.75946054597824, 454.37718779248365, 453.47845051081714, 453.47845051171294, 454.3771877925332, 466.7594605373886, 521.4012716293698, 411.11994645436687, 436.43056687381267, 547.2839198529169, 496.8195999225925, 6237.6392766813115, 17051320.836964116, 141224068230.92807, 46100651686.64556, 41256077627.358154, 139760684405.8389, 43906776.685091354, 25979.096600669953, 383.41207031902223, 453.00745426459594, 455.7977421728649, 458.5406015656039, 463.75960688213377, 489.3260331837166, 507.5181506352368, 430.04852152361303, 418.64761473519997, 499.7149166560006, 462.4372641672895, 453.0602051387522, 451.21934724363126, 451.2193472455834, 453.06020513836495, 462.4372641563967, 499.7148418054974, 418.4749141784713, 430.3016507946167, 507.53274998824696, 489.23857018563103, 463.6184697917532, 458.42797046004426, 455.765639926074, 452.97558064502493, 383.3600816009414, 25580.020168391322, 43140212.65354516, 139797646276.29446, 41294937020.6445] +expected["sol_ring"]["ddt(Pe)"] = [11776992515.278847, 9333976817.33106, -8768088551.261625, -33197517.771432474, -34270.18480201952, -145.42679598603908, -112.78370438917457, -106.29256396898377, -135.79529603103316, -120.70842578547348, -117.5461850393553, -117.31954732388641, -117.3195473246545, -117.5461850395169, -120.70842578416652, -135.79531943747222, -106.26697363481617, -112.84132894906931, -145.3306157431527, -33966.474474843926, -32819414.138547227, -8711967060.982983, 8988831966.472193, 11774163625.297026, 11470405415.916508, 17613943952.708664, -21932747513.197884, -738543641.2932615, -16021286.994439086, -177929.79112491212, -965.1632234118106, -119.97909820884219, -119.91148533793915, -126.7233360862852, -131.600846346435, -111.23505036790579, -108.28315514484545, -130.41884347444665, -119.67717269647282, -117.20648507595878, -116.73123583333035, -116.7312358336583, -117.20648507481415, -119.67717269739042, -130.41884529165083, -108.23762204582864, -111.30025478061458, -131.60183969856658, -126.70037238478437, -119.8753386378501, -119.80520778772954, -886.4583145534157, -163512.84535809705, -14973432.53666446, -705914601.3896351, -21568352970.922516, 15671594099.482447, 11467682961.664255] +expected["sol_ring"]["ddt(NVd+)"] = [27416272.837849542, 29843053.721220404, -98032.75589236667, -0.06937109113426526, -5.7621060006721315e-05, -1.5416103301579583e-08, -5.800811204853931e-11, 2.662459414558923e-11, 4.860318164906013e-11, -8.766558496349684e-11, -1.9647936340500678e-11, -1.2645971729581726e-12, 1.2645971729941652e-12, 1.96479363406296e-11, 8.766558496122037e-11, -4.8368383634201935e-11, -2.654190906792441e-11, 5.812606233673052e-11, 1.5326944688842124e-08, 5.7061367935128635e-05, 0.06916818230231037, 97400.37873759655, 27631783.156227004, 27407006.03364711, 27491543.158813324, 30003774.023675527, -252686.72227618776, -0.5638888269552669, -0.006351576349484462, -8.142885231450911e-05, -4.922229247682577e-07, -1.0550940068772505e-09, 1.848476187145342e-10, 1.4909329445488978e-10, -7.276699197769393e-11, -3.17216721134545e-11, 2.2562199253482067e-11, 4.70379605630196e-11, -8.95091107599747e-11, -2.3647983200904405e-11, -3.841930295861274e-12, 3.8419302958427794e-12, 2.364798319988606e-11, 8.950911076145584e-11, -4.703796055409992e-11, -2.2646386571154443e-11, 3.1895228416937104e-11, 7.34011163613448e-11, -1.4934926274033144e-10, -1.8453534248570585e-10, 9.45965969566738e-10, 4.493438197213855e-07, 7.546030398845405e-05, 0.006002655490103674, 0.5460008969160347, 248208.5951704684, 27475109.04677045, 27414149.056593273] +expected["sol_ring"]["ddt(Pd)"] = [108887226313.79114, 96523619548.54303, 8887870.312733471, 472.20514261453576, 507.04336100390327, 551.0798383315962, 437.45608173504183, 412.2775048346568, 526.6828154678757, 468.20426453097656, 455.9287460035725, 455.0441495392622, 455.0441495422412, 455.92874600419924, 468.20426452590783, 526.6828154883442, 412.17833580226494, 437.6794613945601, 550.7391898636769, 506.8512228811758, 472.086393313632, 8830237.124684855, 96520365396.16295, 108861312368.47324, 106069191289.32428, 96600057528.95305, 22927387.415258802, 468.0371805773448, 454.02111354714, 455.1378079742271, 457.02345381985754, 459.89133973573183, 465.2014846146613, 491.44871128065256, 510.4186700624353, 431.44671945599487, 419.99751237069904, 505.8302295134958, 464.2012908035447, 454.61399787695984, 452.7642718360932, 452.76427183736547, 454.61399787252054, 464.2012908071038, 505.8302295055703, 419.820913680721, 431.6996314410605, 510.4223924249515, 491.3595099916829, 465.05802958550476, 459.7804349367682, 456.9945327577362, 455.1349952772563, 454.0161354495289, 467.66861473231893, 22519464.03739986, 96593187823.64775, 106044601017.12198] # fmt: on @@ -206,6 +218,8 @@ else: ) if len(failures) > 0: + t_final = time() + print(f"2D-production test: Failed in {t_final - t0:.2f} seconds") print("2D-production test failures:") for f in failures: print(f"\n{f['region']} [{f['variable']}]:") @@ -215,5 +229,6 @@ else: else: if verbose: - print("2D-production test: Passed") + t_final = time() + print(f"2D-production test: Passed in {t_final - t0:.2f} seconds") exit(0) diff --git a/tests/integrated/2D-recycling/data/BOUT.inp b/tests/integrated/2D-recycling/data/BOUT.inp index e2014de38..3dd57e522 100644 --- a/tests/integrated/2D-recycling/data/BOUT.inp +++ b/tests/integrated/2D-recycling/data/BOUT.inp @@ -1,6 +1,6 @@ # -nout = 5 # Number of output timesteps +nout = 1 # Number of output timesteps timestep = 0.0001 MZ = 1 diff --git a/tests/integrated/2D-recycling/runtest b/tests/integrated/2D-recycling/runtest index ec64d10d2..3f455644d 100755 --- a/tests/integrated/2D-recycling/runtest +++ b/tests/integrated/2D-recycling/runtest @@ -9,7 +9,9 @@ import os from pathlib import Path import urllib.request import xhermes +from time import time +t0 = time() """ This test reconstructs neutra target density and energy sources due to recycling @@ -64,6 +66,10 @@ if not debug: with open(tmp_path, "wb") as out_file: shutil.copyfileobj(response, out_file) + t_download = time() + if verbose: + print(f"2D-Recycling test: download took {t_download-t0:.2f} seconds") + # Rename temp file with the correct name tmp_path.replace(zipfile_path) @@ -88,8 +94,10 @@ if not debug: "2D-recycling test: downloaded zip file hash does not match expected value" ) + t_extract = time() if verbose: - print("2D-recycling test: downloaded and extracted files") + print(f"2D-Recycling test: zip extraction took {t_extract-t_download:.2f} seconds") + ## Run test if not Path("hermes-3").is_file(): @@ -108,8 +116,9 @@ if not debug: print(out) exit(1) + t_run = time() if verbose: - print("2D-recycling test: completed simulation") + print(f"2D-Recycling test: simulation took {t_run-t_extract:.2f}") ########################################################################## # Load case and perform test @@ -134,6 +143,11 @@ ds = xhermes.open_hermesdataset( ds = ds.hermes.extract_2d_tokamak_geometry() ds = ds.load() + +t_load = time() +if verbose: + print(f"2D-Recycling test: loading results took {t_load - t_run:.2f} seconds") + if "t" in ds.sizes: ds = ds.isel(t=-1) m = ds.metadata @@ -434,3 +448,6 @@ for side in ["upper", "lower"]: atol=atol, err_msg=f"{side} target pump energy source mismatch", ) + +t_final = time() +print(f"2D-Recycling test: Passed in {t_final - t0:.2f} seconds") \ No newline at end of file From 30c402d22279c5787ae31a8ab5cbeecd92510404 Mon Sep 17 00:00:00 2001 From: Mike Kryjak Date: Tue, 24 Mar 2026 12:44:00 +0000 Subject: [PATCH 02/11] 2D-production/recycling: default verbose=true --- tests/integrated/2D-production/runtest | 2 +- tests/integrated/2D-recycling/runtest | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integrated/2D-production/runtest b/tests/integrated/2D-production/runtest index d08f89bb3..39eaa5dcf 100755 --- a/tests/integrated/2D-production/runtest +++ b/tests/integrated/2D-production/runtest @@ -13,7 +13,7 @@ from time import time t0 = time() gen_data = False -verbose = False +verbose = True rtol = 1e-6 atol = 1e-8 diff --git a/tests/integrated/2D-recycling/runtest b/tests/integrated/2D-recycling/runtest index 3f455644d..8921e3798 100755 --- a/tests/integrated/2D-recycling/runtest +++ b/tests/integrated/2D-recycling/runtest @@ -21,7 +21,7 @@ It mirrors the code in recycling.cxx. It's written in a way to allow easy debugg of the recycling calculation for development reasons. """ -verbose = False +verbose = True plot = False debug = False # Do not download files or run test rtol = 1e-6 From 68bb8e93de0f7d949e19875b2176a016c28c369a Mon Sep 17 00:00:00 2001 From: Mike Kryjak Date: Tue, 24 Mar 2026 12:45:18 +0000 Subject: [PATCH 03/11] formatting --- tests/integrated/2D-production/runtest | 9 +++++---- tests/integrated/2D-recycling/runtest | 11 ++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/integrated/2D-production/runtest b/tests/integrated/2D-production/runtest index 39eaa5dcf..3b60107d6 100755 --- a/tests/integrated/2D-production/runtest +++ b/tests/integrated/2D-production/runtest @@ -57,13 +57,12 @@ with urllib.request.urlopen(url, timeout=60) as response: t_download = time() if verbose: - print(f"2D-Production test: download took {t_download-t0:.2f} seconds") + print(f"2D-Production test: download took {t_download - t0:.2f} seconds") # Rename temp file with the correct name tmp_path.replace(zipfile_path) - with zipfile.ZipFile(zipfile_path, "r") as zf: zip_contents = set(zf.namelist()) try: @@ -87,7 +86,9 @@ if file_hash != expected_hash: t_extract = time() if verbose: - print(f"2D-Production test: zip extraction took {t_extract-t_download:.2f} seconds") + print( + f"2D-Production test: zip extraction took {t_extract - t_download:.2f} seconds" + ) ## Run test if not Path("hermes-3").is_file(): @@ -108,7 +109,7 @@ if s != 0: t_run = time() if verbose: - print(f"2D-Production test: simulation took {t_run-t_extract:.2f} seconds") + print(f"2D-Production test: simulation took {t_run - t_extract:.2f} seconds") # Load case ds = xhermes.open_hermesdataset( diff --git a/tests/integrated/2D-recycling/runtest b/tests/integrated/2D-recycling/runtest index 8921e3798..6b6d0a022 100755 --- a/tests/integrated/2D-recycling/runtest +++ b/tests/integrated/2D-recycling/runtest @@ -68,7 +68,7 @@ if not debug: t_download = time() if verbose: - print(f"2D-Recycling test: download took {t_download-t0:.2f} seconds") + print(f"2D-Recycling test: download took {t_download - t0:.2f} seconds") # Rename temp file with the correct name tmp_path.replace(zipfile_path) @@ -96,8 +96,9 @@ if not debug: t_extract = time() if verbose: - print(f"2D-Recycling test: zip extraction took {t_extract-t_download:.2f} seconds") - + print( + f"2D-Recycling test: zip extraction took {t_extract - t_download:.2f} seconds" + ) ## Run test if not Path("hermes-3").is_file(): @@ -118,7 +119,7 @@ if not debug: t_run = time() if verbose: - print(f"2D-Recycling test: simulation took {t_run-t_extract:.2f}") + print(f"2D-Recycling test: simulation took {t_run - t_extract:.2f}") ########################################################################## # Load case and perform test @@ -450,4 +451,4 @@ for side in ["upper", "lower"]: ) t_final = time() -print(f"2D-Recycling test: Passed in {t_final - t0:.2f} seconds") \ No newline at end of file +print(f"2D-Recycling test: Passed in {t_final - t0:.2f} seconds") From b016281355d0c8c5da8acc5620cd5a9a653c8686 Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:30:04 +0000 Subject: [PATCH 04/11] Add default target granularity variable for sed to search and replace in docker image. --- spack.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spack.yaml b/spack.yaml index 95222362c..06faed1b4 100644 --- a/spack.yaml +++ b/spack.yaml @@ -21,6 +21,8 @@ spack: link_type: symlink concretizer: unify: when_possible + targets: + granularity: microarchitectures repos: - ./external/BOUT-spack/spack_repo/bout - ./external/Reactions/VANTAGE-repo From 08810e3d92731c1497bf7e75fb373b59a21194f0 Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:39:59 +0000 Subject: [PATCH 05/11] Change docker image name, use sed to use generic target granularity in spack-installed tests. --- .../workflows/build_docker_VANTAGE_dependencies_image.yml | 2 +- .github/workflows/docker_VANTAGE_tests.yml | 6 ++++-- VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml index 57bb82464..727b2f241 100644 --- a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml +++ b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml @@ -10,7 +10,7 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: UKAEA-Edge-Code/hermes-3 + IMAGE_NAME: UKAEA-Edge-Code/hermes-3-vantage-deps DOCKERFILE: VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile permissions: diff --git a/.github/workflows/docker_VANTAGE_tests.yml b/.github/workflows/docker_VANTAGE_tests.yml index 52d55332b..aed7a0a6e 100644 --- a/.github/workflows/docker_VANTAGE_tests.yml +++ b/.github/workflows/docker_VANTAGE_tests.yml @@ -14,7 +14,7 @@ jobs: # timeout to avoid running tests which do unexpected spack installation timeout-minutes: 45 container: - image: ghcr.io/ukaea-edge-code/hermes-3:edge + image: ghcr.io/ukaea-edge-code/hermes-3-vantage-deps:edge credentials: username: ${{ github.actor }} password: ${{ secrets.github_token }} @@ -30,6 +30,7 @@ jobs: submodules: recursive - name: Check download run: source /opt/spack/share/spack/setup-env.sh && + sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && spack env activate . -v gcc && spack concretize -f && spack env view regenerate && @@ -40,9 +41,10 @@ jobs: # python3 2D-production-download.py && - name: Install run: source /opt/spack/share/spack/setup-env.sh && + sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && spack env activate . -v gcc && spack concretize -f && - spack install -j 4 + spack install -j 4 --only-concrete - name : Run tests run: source /opt/spack/share/spack/setup-env.sh && spack env activate . -v gcc && diff --git a/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile b/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile index 55023761c..90d4fcf26 100644 --- a/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile +++ b/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile @@ -24,7 +24,9 @@ WORKDIR /root/hermes-3 # Install hermes-3 dependencies via spack # Activate the hermes-3 environment, install dependencies -RUN < Date: Wed, 25 Mar 2026 16:44:35 +0000 Subject: [PATCH 06/11] Build docker image on push. --- .github/workflows/build_docker_VANTAGE_dependencies_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml index 727b2f241..072b186da 100644 --- a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml +++ b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml @@ -5,7 +5,7 @@ name: Build hermes-3+vantagereactions dependencies Docker image on: push: branches: - - 'VANTAGE-Reactions-Coupling/dev' + - ** workflow_dispatch: # Allows manual triggering env: From 9711f55b7ff11db6b13641934eb023efb4ef12da Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Wed, 25 Mar 2026 16:51:36 +0000 Subject: [PATCH 07/11] Attempt to correct syntax. --- ...uild_docker_VANTAGE_dependencies_image.yml | 2 +- .github/workflows/docker_VANTAGE_tests.yml | 49 ++++++++++--------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml index 072b186da..f35ae6dfa 100644 --- a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml +++ b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml @@ -5,7 +5,7 @@ name: Build hermes-3+vantagereactions dependencies Docker image on: push: branches: - - ** + - '**' workflow_dispatch: # Allows manual triggering env: diff --git a/.github/workflows/docker_VANTAGE_tests.yml b/.github/workflows/docker_VANTAGE_tests.yml index aed7a0a6e..0b542baf6 100644 --- a/.github/workflows/docker_VANTAGE_tests.yml +++ b/.github/workflows/docker_VANTAGE_tests.yml @@ -29,28 +29,31 @@ jobs: with: submodules: recursive - name: Check download - run: source /opt/spack/share/spack/setup-env.sh && - sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && - spack env activate . -v gcc && - spack concretize -f && - spack env view regenerate && - spack find && which python3 && - chmod +x 2D-production-download.py && - mkdir download-dir && cp 2D-production-download.py download-dir/ && - cd download-dir && ./2D-production-download.py && ls - # python3 2D-production-download.py && + run: | + source /opt/spack/share/spack/setup-env.sh && + sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && + spack env activate . -v gcc && + spack concretize -f && + spack env view regenerate && + spack find && which python3 && + chmod +x 2D-production-download.py && + mkdir download-dir && cp 2D-production-download.py download-dir/ && + cd download-dir && ./2D-production-download.py && ls + # python3 2D-production-download.py && - name: Install - run: source /opt/spack/share/spack/setup-env.sh && - sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && - spack env activate . -v gcc && - spack concretize -f && - spack install -j 4 --only-concrete + run: | + source /opt/spack/share/spack/setup-env.sh && + sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && + spack env activate . -v gcc && + spack concretize -f && + spack install -j 4 --only-concrete - name : Run tests - run: source /opt/spack/share/spack/setup-env.sh && - spack env activate . -v gcc && - chmod +x 2D-production-download.py && - cp 2D-production-download.py $(spack location -b hermes-3)/tests/integrated/2D-production/ && - spack cd -b hermes-3 && - ./tests/integrated/2D-production/./2D-production-download.py && - ls ./tests/integrated/2D-production/ && - ctest -j 1 --output-on-failure --timeout 300 -VV + run: | + source /opt/spack/share/spack/setup-env.sh && + spack env activate . -v gcc && + chmod +x 2D-production-download.py && + cp 2D-production-download.py $(spack location -b hermes-3)/tests/integrated/2D-production/ && + spack cd -b hermes-3 && + ./tests/integrated/2D-production/./2D-production-download.py && + ls ./tests/integrated/2D-production/ && + ctest -j 1 --output-on-failure --timeout 300 -VV From 7d48949c5d381b8881256579655237afa1fae316 Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Thu, 26 Mar 2026 13:37:52 +0000 Subject: [PATCH 08/11] Use sed to set `target=x86_64_v3` in docker image and VANTAGE tests. --- .github/workflows/docker_VANTAGE_tests.yml | 27 ++++++++++--------- .../hermes-3-VANTAGE-dependencies.dockerfile | 10 +++++++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker_VANTAGE_tests.yml b/.github/workflows/docker_VANTAGE_tests.yml index 0b542baf6..f07fee904 100644 --- a/.github/workflows/docker_VANTAGE_tests.yml +++ b/.github/workflows/docker_VANTAGE_tests.yml @@ -12,7 +12,7 @@ jobs: docker_spack_install_tests: runs-on: ubuntu-latest # timeout to avoid running tests which do unexpected spack installation - timeout-minutes: 45 + timeout-minutes: 35 container: image: ghcr.io/ukaea-edge-code/hermes-3-vantage-deps:edge credentials: @@ -28,22 +28,23 @@ jobs: uses: actions/checkout@v6 with: submodules: recursive - - name: Check download - run: | - source /opt/spack/share/spack/setup-env.sh && - sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && - spack env activate . -v gcc && - spack concretize -f && - spack env view regenerate && - spack find && which python3 && - chmod +x 2D-production-download.py && - mkdir download-dir && cp 2D-production-download.py download-dir/ && - cd download-dir && ./2D-production-download.py && ls - # python3 2D-production-download.py && + # - name: Check download + # run: | + # source /opt/spack/share/spack/setup-env.sh && + # sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && + # spack env activate . -v gcc && + # spack concretize -f && + # spack env view regenerate && + # spack find && which python3 && + # chmod +x 2D-production-download.py && + # mkdir download-dir && cp 2D-production-download.py download-dir/ && + # cd download-dir && ./2D-production-download.py && ls + # # python3 2D-production-download.py && - name: Install run: | source /opt/spack/share/spack/setup-env.sh && sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && + sed -i '/^[[:space:]]*providers:/i\ require: "target=x86_64_v3"' spack.yaml && spack env activate . -v gcc && spack concretize -f && spack install -j 4 --only-concrete diff --git a/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile b/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile index 90d4fcf26..8ef889b80 100644 --- a/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile +++ b/VANTAGE-docker/hermes-3-VANTAGE-dependencies.dockerfile @@ -27,6 +27,16 @@ WORKDIR /root/hermes-3 RUN < Date: Fri, 27 Mar 2026 09:43:17 +0000 Subject: [PATCH 09/11] Tidy up test workflow. --- .github/workflows/docker_VANTAGE_tests.yml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/.github/workflows/docker_VANTAGE_tests.yml b/.github/workflows/docker_VANTAGE_tests.yml index f07fee904..eefea0d49 100644 --- a/.github/workflows/docker_VANTAGE_tests.yml +++ b/.github/workflows/docker_VANTAGE_tests.yml @@ -28,18 +28,6 @@ jobs: uses: actions/checkout@v6 with: submodules: recursive - # - name: Check download - # run: | - # source /opt/spack/share/spack/setup-env.sh && - # sed -i 's/^[[:space:]]*granularity:[[:space:]]*microarchitectures/ granularity: generic/' spack.yaml && - # spack env activate . -v gcc && - # spack concretize -f && - # spack env view regenerate && - # spack find && which python3 && - # chmod +x 2D-production-download.py && - # mkdir download-dir && cp 2D-production-download.py download-dir/ && - # cd download-dir && ./2D-production-download.py && ls - # # python3 2D-production-download.py && - name: Install run: | source /opt/spack/share/spack/setup-env.sh && @@ -52,9 +40,5 @@ jobs: run: | source /opt/spack/share/spack/setup-env.sh && spack env activate . -v gcc && - chmod +x 2D-production-download.py && - cp 2D-production-download.py $(spack location -b hermes-3)/tests/integrated/2D-production/ && spack cd -b hermes-3 && - ./tests/integrated/2D-production/./2D-production-download.py && - ls ./tests/integrated/2D-production/ && - ctest -j 1 --output-on-failure --timeout 300 -VV + ctest -j 1 --output-on-failure --timeout 300 From 5c8797d33b56e1212eee1a245b84aa4959e61e8d Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Fri, 27 Mar 2026 09:43:44 +0000 Subject: [PATCH 10/11] Tidy up 2D-production test. --- 2D-production-download.py | 80 ----------------------- tests/integrated/2D-production/runtest | 89 +++++++++++++------------- 2 files changed, 44 insertions(+), 125 deletions(-) delete mode 100644 2D-production-download.py diff --git a/2D-production-download.py b/2D-production-download.py deleted file mode 100644 index 4725da8ae..000000000 --- a/2D-production-download.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python3 -import numpy as np -import shutil -import zipfile -import hashlib -import os -from pathlib import Path -import urllib.request - -verbose = True -rtol = 1e-6 -atol = 1e-8 - -## Setup -this_dir = Path(__file__).parent - -zipfile_path = this_dir / "test-2D-production.zip" -url = "https://zenodo.org/records/18696440/files/test-2D-production-2026-02-19.zip" -expected_hash = "4472d27031a6fcedd30e11360814a66c075f8c14442df745e4e9d80a0dbd87f3" -expected_filenames = [ - "BOUT.restart.0.nc", - "BOUT.restart.1.nc", - "BOUT.restart.2.nc", - "BOUT.restart.3.nc", - "BOUT.restart.4.nc", - "BOUT.restart.5.nc", - "BOUT.restart.6.nc", - "BOUT.restart.7.nc", - "BOUT.restart.8.nc", - "BOUT.restart.9.nc", - "grid_test2_allpump.nc", -] - -if verbose: - print("2D-Production test: begin file download") - -## Download files -tmp_path = zipfile_path.with_name(zipfile_path.name + ".tmp") - -with urllib.request.urlopen(url, timeout=60) as response: - if response.status != 200: - raise RuntimeError( - f"2D-Production test: download failed - HTTP {response.status}" - ) - - # Copy bits of the file from response to a temp file - # This ensures no partial files are left if the download fails - with open(tmp_path, "wb") as out_file: - shutil.copyfileobj(response, out_file) - - -if verbose: - print("2D-Production test: downloaded files") - -# Rename temp file with the correct name -tmp_path.replace(zipfile_path) - -with zipfile.ZipFile(zipfile_path, "r") as zf: - zip_contents = set(zf.namelist()) - try: - # Extract only expected grids - for filename in expected_filenames: - if filename in zip_contents: - zf.extract(filename, path=this_dir) - - except Exception as e: - print("2D-Production test: extracting test grids failed:", e) - -# Check hash -with open(zipfile_path, "rb") as f: - file_hash = hashlib.sha256(f.read()).hexdigest() -# print(file_hash) - -if file_hash != expected_hash: - raise RuntimeError( - "2D-Production test: downloaded zip file hash does not match expected value" - ) - -if verbose: - print("2D-Production test: downloaded and extracted files") \ No newline at end of file diff --git a/tests/integrated/2D-production/runtest b/tests/integrated/2D-production/runtest index 9b2848106..85dbd2f40 100755 --- a/tests/integrated/2D-production/runtest +++ b/tests/integrated/2D-production/runtest @@ -48,54 +48,53 @@ expected_filenames = [ "grid_test2_allpump.nc", ] print(f"step 1: {time() - t0}") -if not Path(this_dir / expected_filenames[-1]).is_file(): - ## Download files - print(f"step 1 attempt to download files: {time() - t0}") - tmp_path = zipfile_path.with_name(zipfile_path.name + ".tmp") - - with urllib.request.urlopen(url, timeout=60) as response: - if response.status != 200: - raise RuntimeError( - f"2D-Production test: download failed - HTTP {response.status}" - ) - - # Copy bits of the file from response to a temp file - # This ensures no partial files are left if the download fails - with open(tmp_path, "wb") as out_file: - shutil.copyfileobj(response, out_file) - - t_download = time() - if verbose: - print(f"2D-Production test: download took {t_download - t0:.2f} seconds") - # Rename temp file with the correct name - tmp_path.replace(zipfile_path) - print(f"step 1: attempt to extract files {time() - t0}") - with zipfile.ZipFile(zipfile_path, "r") as zf: - zip_contents = set(zf.namelist()) - try: - # Extract only expected grids - for filename in expected_filenames: - if filename in zip_contents: - zf.extract(filename, path=this_dir) - - except Exception as e: - print("2D-Production test: extracting test grids failed:", e) - - # Check hash - with open(zipfile_path, "rb") as f: - file_hash = hashlib.sha256(f.read()).hexdigest() - # print(file_hash) - - if file_hash != expected_hash: +## Download files +print(f"step 1 attempt to download files: {time() - t0}") +tmp_path = zipfile_path.with_name(zipfile_path.name + ".tmp") + +with urllib.request.urlopen(url, timeout=60) as response: + if response.status != 200: raise RuntimeError( - "2D-Production test: downloaded zip file hash does not match expected value" + f"2D-Production test: download failed - HTTP {response.status}" ) - t_extract = time() - if verbose: - print( - f"2D-Production test: zip extraction took {t_extract - t_download:.2f} seconds" - ) + # Copy bits of the file from response to a temp file + # This ensures no partial files are left if the download fails + with open(tmp_path, "wb") as out_file: + shutil.copyfileobj(response, out_file) + +t_download = time() +if verbose: + print(f"2D-Production test: download took {t_download - t0:.2f} seconds") +# Rename temp file with the correct name +tmp_path.replace(zipfile_path) +print(f"step 1: attempt to extract files {time() - t0}") +with zipfile.ZipFile(zipfile_path, "r") as zf: + zip_contents = set(zf.namelist()) + try: + # Extract only expected grids + for filename in expected_filenames: + if filename in zip_contents: + zf.extract(filename, path=this_dir) + + except Exception as e: + print("2D-Production test: extracting test grids failed:", e) + +# Check hash +with open(zipfile_path, "rb") as f: + file_hash = hashlib.sha256(f.read()).hexdigest() +# print(file_hash) + +if file_hash != expected_hash: + raise RuntimeError( + "2D-Production test: downloaded zip file hash does not match expected value" + ) + +t_extract = time() +if verbose: + print( + f"2D-Production test: zip extraction took {t_extract - t_download:.2f} seconds" + ) print(f"step 2: {time() - t0}") ## Run test From ac67a27de32f8d719cc12d1bb8fff03031bd6a1f Mon Sep 17 00:00:00 2001 From: Michael Hardman <29800382+mrhardman@users.noreply.github.com> Date: Fri, 27 Mar 2026 09:45:29 +0000 Subject: [PATCH 11/11] Build docker image on push to `VANTAGE-Reactions-Coupling/dev`. --- .github/workflows/build_docker_VANTAGE_dependencies_image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml index f35ae6dfa..727b2f241 100644 --- a/.github/workflows/build_docker_VANTAGE_dependencies_image.yml +++ b/.github/workflows/build_docker_VANTAGE_dependencies_image.yml @@ -5,7 +5,7 @@ name: Build hermes-3+vantagereactions dependencies Docker image on: push: branches: - - '**' + - 'VANTAGE-Reactions-Coupling/dev' workflow_dispatch: # Allows manual triggering env: