diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 079b18dc6..c319ee705 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -56,7 +56,7 @@ jobs: - name: Install pip packages run: | - ./.pip_install_for_tests.sh 'netcdf4~=1.5' 'boutdata==0.3.0' boututils + ./.pip_install_for_tests.sh 'netcdf4~=1.5' 'boutdata==0.3.0' boututils 'git+https://github.com/boutproject/zoidberg' # Add the pip install location to the runner's PATH echo ~/.local/bin >> $GITHUB_PATH - name: Build and run tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 9eae66871..99f0cf1fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -245,6 +245,14 @@ add_custom_command(TARGET setup-test PRE_BUILD if(HERMES_TESTS) enable_testing() + if (BOUT_ENABLE_METRIC_3D) + add_custom_command(TARGET setup-test PRE_BUILD + COMMAND python3 ./generate_axial_circular.py + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/grids + ) + file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/grids ${CMAKE_CURRENT_BINARY_DIR}/grids SYMBOLIC) + endif() + # Integrated tests function(hermes_add_integrated_test TESTNAME) set(oneValueArgs DOWNLOAD DOWNLOAD_NAME) @@ -298,6 +306,10 @@ if(HERMES_TESTS) DEPENDS setup-test) endif() endfunction() + hermes_add_integrated_test(3D-Axial-circular-conduction-fci + REQUIRES BOUT_ENABLE_METRIC_3D) + hermes_add_integrated_test(2D-axial-circular-fci + REQUIRES BOUT_ENABLE_METRIC_3D) hermes_add_integrated_test(2D-vorticity-inversion-fci REQUIRES BOUT_ENABLE_METRIC_3D) hermes_add_integrated_test(1D-sheathtest-recycling-fci diff --git a/grids/generate_axial_circular.py b/grids/generate_axial_circular.py new file mode 100644 index 000000000..564912162 --- /dev/null +++ b/grids/generate_axial_circular.py @@ -0,0 +1,92 @@ +import zoidberg +from zoidberg.field import Slab +import numpy as np + +import os +import sys + +class Axial_circular(Slab): + def __init__(self,rho_1,rho_2,Lz,By,R0, q0 = 3.0, q1 = 0.2): + self.rho_1 = float(rho_1) + self.rho_2 = float(rho_2) + self.Lz = float(Lz) + self.By = float(By) + self.R0 = R0 + + def qprofile(self,x,z,phi): + theta=np.arctan2(z,x-self.R0) + r = np.sqrt(np.power(x-self.R0,2)+np.power(z,2)) + return q0 + q1 * r + + def Bxfunc(self,x,z,phi): + theta=np.arctan2(z,x-self.R0) + r = np.sqrt(np.power(x-self.R0,2)+np.power(z,2)) + q = self.qprofile(x,z,phi) + return -r * np.sin(theta) / q + + def Bzfunc(self,x,z,phi): + theta=np.arctan2(z,x-self.R0) + r = np.sqrt(np.power(x-self.R0,2)+np.power(z,2)) + q = self.qprofile(x,z,phi) + return r * np.cos(theta) / q + + def Byfunc(self,x,z,phi): + return np.full(x.shape,self.By) + + + + +R0 = 1.5 +rho_1 = 0.4 +rho_2 = 0.6 +B0 = 1.0 +Ly = 2.0 * np.pi +q0 = 3.0 +q1 = 0.0 +field = Axial_circular(rho_1, rho_2, Ly, B0,R0, q0=q0, q1=q1) + +folder = "mms_axial_circular_fci/" + +if not os.path.exists(folder): + os.mkdir(folder) + +force = "-f" in sys.argv or "--force" in sys.argv + + + +for scale in [1,2]: + nx = scale * 16 + nz = scale * 64 + ny = scale * 8 + + filename = f"Axial_circular_q_{nx}_{nz}_{rho_1}_{rho_2}_{q0}_{q1}.fci.grid.nc" + fn = folder + filename + + if os.path.exists(fn) and not force: + print(fn, " exists") + continue + + + inner = zoidberg.rzline.shaped_line(R0=R0,a=rho_1,n=nz) + outer = zoidberg.rzline.shaped_line(R0=R0,a=rho_2,n=nz) + + pol_grid = zoidberg.poloidal_grid.grid_annulus(inner,outer,nx+4,nz) + pol_grids = [] + for i in range(ny): + pol_grids.append(pol_grid) + + grid = zoidberg.grid.Grid(pol_grids, np.linspace(0.0, 2.0 * np.pi, ny, endpoint=False),Ly,yperiodic=True) + maps = zoidberg.zoidberg.make_maps(grid, field) + + maps["forward_xt_prime"][2,:,:] = 2.0 + maps["backward_xt_prime"][2,:,:] = 2.0 + + maps["forward_xt_prime"][-3,:,:] = float(nx+4-3) + maps["backward_xt_prime"][-3,:,:] = float(nx+4-3) + + with zoidberg.zoidberg.MapWriter(fn) as mw: + mw.add_grid_field(grid, field) + mw.add_maps(maps) + mw.add_dagp() + + print(fn, " done") diff --git a/tests/integrated/2D-axial-circular-fci/axial.m b/tests/integrated/2D-axial-circular-fci/axial.m new file mode 100644 index 000000000..852e558e7 --- /dev/null +++ b/tests/integrated/2D-axial-circular-fci/axial.m @@ -0,0 +1,72 @@ +(* ::Package:: *) + +BeginPackage["axial`"] + +(* To run the package, execute the following line in a notebook +<Normal*) + +(* Beginning of Notebook Content *) +Notebook[{ + +Cell[CellGroupData[{ +Cell[BoxData[ + RowBox[{"\[IndentingNewLine]", + RowBox[{"SetDirectory", "[", + RowBox[{"NotebookDirectory", "[", "]"}], "]"}]}]], "Input", + CellChangeTimes->{{3.941091023755059*^9, 3.941091026844414*^9}}, + CellLabel->"In[1]:=",ExpressionUUID->"a48e709c-4f46-4e32-b340-a589ee6f1552"], + +Cell[BoxData["\<\"/viper/u1/toto/soft/hermes-3/build_new/tests/integrated/2D-\ +axial-circular-fci\"\>"], "Output", + CellChangeTimes->CompressedData[" +1:eJwVy1kowwEcwPHxMLNG26zYJVeMB1JWayXNgwchhCgzZLnKtVjzgMgRC1PU +lBQNY9gaC+XIPXeOB8ymZA/4L1HacuT3e/j2efqGltZmy71IJFIydEZfuKNI +CcknozjEF6x3yrRUMHX/8hA9tdoa6GDhRroBZexfRDPAZo73IBPcbI2cQytq +NLsscFWYlBMIjgg7pGgWhTzEBp9ahqO5oID6K0IvU8YFPNCuCE9HDeVvGjRV +dpLAB0tc4i7Uh6oYCAYzVfQ6KVh2olKiXaYDfRH4OifiFoNnllIF+vb4bUXP +Jw7ZJeDFPCcOHW8SJ6LVn3lb6Lsx4g8N8vRM3YIU/rAF5emFVpS/1qizgbmd +T3uoa5J6j6pF0040gzgOfABnI41mO9gksi07wKUxecoj2O0ZuHkGP3SVZCeY +P1PnRj9ebKO0IkJCO/DdRtWSDDFtBn4zj0Dp0rYoPzCbHZuDDlWbtWi/qj3e +H3TdTbcyQSUzZgN1d5N7A0A1/0iLFlSt61H3D/cI/RkxpukMhCT5SuNAWWFf +L2ifoPJrEbxW9wUYwRXTTi76D+TiDJ0= + "], + CellLabel->"Out[1]=",ExpressionUUID->"0e0ce5db-9968-4678-bade-a56ea533da98"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"<<", "axial.m"}]], "Input", + CellChangeTimes->{{3.9410005336133223`*^9, 3.941000541398674*^9}, { + 3.941000701368867*^9, 3.941000721827975*^9}, {3.941000869088725*^9, + 3.941000881063511*^9}, 3.941091017550275*^9}, + CellLabel->"In[2]:=",ExpressionUUID->"9f707231-815c-446a-a783-4c26634eb7ef"], + +Cell[CellGroupData[{ + +Cell[BoxData["\<\"Computing MMS Terms\"\>"], "Print", + CellChangeTimes->CompressedData[" +1:eJwVzFsoswEcx/GR42JjzsflUA4XSIjl9NwgtZIkZHt5JeWcidQu5hCzKexC +oXYhh4XhwphEksjzlguhVxg5az2KiyVD/r+Lb5+7b8TfluJaBx6Pl0uNO7pP +8mUc43TXx0JJ+anCi9TdRxshT1AX703eOA+PiEhuQb0Ala3WPV94P1cSQOYl +OMphxVOjLohs09rjQkhWVZkBFf8840LJWMGUFH4OMDrobBGnhpE5p2P90E38 +MhxOmnu7WmXkUYOtE/pPd8zLyZijsZAqskW/ooC+tgYWtk8nBVeTdtFBIswt +m82C74NLO7Cn0PADT/SZc+fksdq0DvWpW4dwl32YuSQ30pb3oZfr5gWsL8p+ +gtaTxMArMlytWbWQ/CjD2jX55zsr/wbf7uizB1Lz/OjySJ7d2T9ggck06SHn +mEjF7S4sSDdLPAwcU5k5zkGZ3CXWk1Q1GUugtC9lAn65CZMFpMQ7VCUie5Tb +27CZr9T4kAJxzQQc+iydh9qiURYaLULpzCLH7AT8v4bZ3/lW6Cdkbcvkq/+b +zwqpLY4vhb+8mP+k + "], + CellLabel-> + "During evaluation of \ +In[2]:=",ExpressionUUID->"473cff57-8647-4b4c-bf0c-4d5eaa3b6b82"], + +Cell[BoxData["\<\"Finished MMS Terms\"\>"], "Print", + CellChangeTimes->CompressedData[" +1:eJwVzE1ImgEcx3EXWU1My97LKa2gGqPGqGhS1nNZEQgRIdtIWxsRrJWRsRh4 +cCabWWB5CErwMGqJZXXI5hiTiNjoCTqMikbNYmkvyBPUQUJX9P8dvnxu3/xX +uuaOOzwer46aiLvrEGg4Jv7IzELF8219CmkPFnogT9T5IJU85NtGJSQ3a5mF +ht7wWjoMzrRkkU9L47Twxclbew7ZNxwrySNZY+sTqN9ILpGSxaLPKhj9xNgh +PyCvuEfWbo9/hEnyM5uM9A2+79WQm12RAZg59c6tJYs2x/Nekjrnoh6mR7pY +2D/1KLedjEl+lcG6Z19q4OXQ/Ao0Nbpu4JazeuYP+dvi/QqdFT/W4Sobmt4n +v1Uu/IQpid/34Jsm5QkMb5Vl/yVlFutSgBQUuJYPyLbrmvpDfD8U7oRI6+lx +wjG5cxS7gg1er0Oo5Zj7+n+rsKHKpxC6OKa1eoKDGm1CcTJp7Pa0QJW5fBL+ +TxI/FpGKVKlRQpoMfj/sERisaaRI/noSjkTVbjjcNMZCT0Csmp7jmJWs3QOo +vK4PwwwxG1kgzzMv0hbJeOdDNbwFuoD/aw== + "], + CellLabel-> + "During evaluation of \ +In[2]:=",ExpressionUUID->"f5b098b0-d445-4178-844e-9ad69a9178f4"], + +Cell[BoxData["9.579629665962438`*^7"], "Print", + CellChangeTimes->CompressedData[" +1:eJwVzE1ImgEcx3EnqzkpTWu1VVNWwWqHOaJiSW9Ph4qBIENihdobMagtI6MI +PDiTzSyoPAQVeAhdknN1mNWIImJs7Ak8jIqiMul9yDOog0Rm7P87fPncvk+a +Da9b7/B4vApqnH9/UqjjmLtHVhYq6zaNSaTjOMcHeaK3zyRkKG54REpyXpsX +mjrDP1Lg8bQmjax6ztfD+rN3jkdk12A0L4NkzdpiaFxPzMskc0VTKnj9iXHA +uKC88DFZvjn2EQrkf4dl5GJ/X6eODLRHemGqq2dGTz4NjGU0kgbnnBGmRNpZ +2O16kd5ERqW/FLDizedSeDnwdRVaXnlu4YazZHqH/GPzL0Bn4fJvuMaeuPfI +70WzP2HSvaVd2KYuO4PhDcXDfVJms38LksJsz/wB2RArrQ7h+yFn64S0n5/G +n5JbR9ErWOP3TyboOSbLeLgGa14uKhM8HKMtGeegTh+fm0ia3/s0UGUtmIA3 +AnG+iFRKMs1S0mJaWYEdQpM9mRTJWybg0HXtDBxUj7LQFxSr3F84ZjVt+wCW +xarD8IGYjcyS/1IvkufISKWiFv4Hv54AEw== + "], + CellLabel-> + "During evaluation of \ +In[2]:=",ExpressionUUID->"3f9194e7-81e0-4b9d-9d98-51875d993cd6"] +}, Open ]] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[{ + RowBox[{ + RowBox[{"kx", " ", "=", "1.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"kz", "=", "4"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"ky", "=", "1"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"omega", "=", "0.1"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"amp", "=", "0.5"}], ";"}], "\[IndentingNewLine]", + RowBox[{"phz", " ", "=", " ", "0.1"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"phy", " ", "=", "0.5"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"pht", "=", " ", "0.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"xmin", "=", "0.4"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"xmax", "=", "0.6"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"offset", " ", "=", " ", "1.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Dperp", " ", "=", " ", "1.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Dpar", " ", "=", " ", "2000"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{ + RowBox[{"q", "[", "x_", "]"}], " ", "=", " ", + RowBox[{"3.0", "+", + RowBox[{"0.0", " ", "*", " ", "x"}]}]}], ";"}], + "\[IndentingNewLine]"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"CForm", "[", + RowBox[{"MmsDens", "[", + RowBox[{"xl", ",", "zl", ",", "yl", ",", "t"}], "]"}], "]"}], + "\[IndentingNewLine]"}], "\[IndentingNewLine]"}], "Input", + CellChangeTimes->{{3.941001710751292*^9, 3.941001799493569*^9}, { + 3.94100196287262*^9, 3.94100197699585*^9}, {3.941002082278537*^9, + 3.941002091026224*^9}, {3.941005604446062*^9, 3.9410056280492363`*^9}, { + 3.941005702954153*^9, 3.941005712874386*^9}, {3.941005747843405*^9, + 3.94100575324975*^9}, {3.941009187354603*^9, 3.941009247364457*^9}, { + 3.94100966318116*^9, 3.941009680024501*^9}, {3.941091600565372*^9, + 3.9410916014166613`*^9}, {3.941091731467869*^9, 3.941091794275579*^9}, { + 3.941091841698888*^9, 3.94109184990349*^9}, {3.94110656901536*^9, + 3.941106579582962*^9}, {3.941106650936283*^9, 3.94110669207623*^9}, + 3.941106732865182*^9, {3.941120562846257*^9, 3.941120568623769*^9}, { + 3.941120627216084*^9, 3.941120628259906*^9}, {3.941120719254148*^9, + 3.941120719910901*^9}, {3.941120781889386*^9, 3.941120787474683*^9}, { + 3.9411251832829638`*^9, 3.941125233701482*^9}, {3.941128545834157*^9, + 3.9411285503249607`*^9}, {3.9411285973137712`*^9, 3.941128604556089*^9}, { + 3.941130823020509*^9, 3.941130836706815*^9}, {3.941132669299409*^9, + 3.9411326822525787`*^9}, {3.9411333416570683`*^9, 3.941133341715454*^9}, { + 3.9411354363450203`*^9, 3.941135441093075*^9}, {3.941137102236459*^9, + 3.941137103929172*^9}, {3.941212667495749*^9, 3.9412126703613577`*^9}, { + 3.941264227933763*^9, 3.941264274028784*^9}, {3.941266728760947*^9, + 3.941266734322445*^9}, {3.941269687955462*^9, 3.9412696987061653`*^9}, { + 3.941271079546174*^9, 3.941271081196938*^9}, {3.9412719962761*^9, + 3.941271997015006*^9}, {3.9412730616699057`*^9, 3.941273066087247*^9}, { + 3.941273533132288*^9, 3.94127355265935*^9}, {3.941273899665763*^9, + 3.941273921460822*^9}, {3.9415184110422688`*^9, 3.9415184170689363`*^9}, { + 3.9415185124635487`*^9, 3.9415185185770617`*^9}, {3.9415188636598063`*^9, + 3.94151886756817*^9}, 3.9415321328707323`*^9, {3.9415427858429737`*^9, + 3.941542828000198*^9}, {3.941542872244955*^9, 3.941542873488117*^9}, { + 3.941543280452444*^9, 3.941543353814756*^9}, {3.941543921314495*^9, + 3.941543944142756*^9}, {3.94154588614583*^9, 3.941545886200872*^9}, { + 3.941551072132766*^9, 3.94155107423029*^9}, {3.941622928218151*^9, + 3.941622975931859*^9}, {3.9416232368015337`*^9, 3.941623242079863*^9}, { + 3.980418501299036*^9, 3.980418510848222*^9}, {3.980419223612973*^9, + 3.9804192259502373`*^9}, {3.980419424952941*^9, 3.9804194250073843`*^9}, { + 3.9804234906671753`*^9, 3.980423505726005*^9}, {3.980441355886915*^9, + 3.980441368363199*^9}, {3.982829754504801*^9, 3.982829782740342*^9}, { + 3.9828299614012003`*^9, 3.982829964662109*^9}, {3.982831344310981*^9, + 3.9828313473575497`*^9}, {3.98285198331588*^9, 3.982851984615147*^9}, { + 3.9828527440353117`*^9, 3.9828527456692553`*^9}}, + CellLabel->"In[3]:=",ExpressionUUID->"595ab9b8-3e80-4f0d-9d22-14a98dc670e3"], + +Cell[BoxData["0.1`"], "Output", + CellChangeTimes->{ + 3.941009688547415*^9, 3.941091609619776*^9, {3.941091721815781*^9, + 3.94109175661007*^9}, 3.941091800122217*^9, 3.941091861807825*^9, + 3.941094505048383*^9, 3.941094632399669*^9, 3.94109500239986*^9, + 3.941106598058303*^9, 3.94110669394636*^9, 3.941106733977233*^9, + 3.9411070572842493`*^9, 3.941108055401798*^9, 3.941110920195258*^9, + 3.941111135388945*^9, 3.9411154343472643`*^9, 3.941120680145395*^9, + 3.941120754512067*^9, 3.941120792306068*^9, 3.941125270776736*^9, + 3.9411285314437933`*^9, 3.94112865354068*^9, 3.9411305706981773`*^9, + 3.941130863732583*^9, 3.941131412892272*^9, 3.941132715845481*^9, + 3.941133367217663*^9, 3.94113549000552*^9, 3.9412642619733667`*^9, + 3.941264321927586*^9, 3.941266776146008*^9, 3.941269726592196*^9, + 3.9412704321241703`*^9, 3.941271127788968*^9, 3.941271764441196*^9, + 3.941271938828134*^9, 3.941272048248835*^9, 3.9412730959363823`*^9, + 3.941273591507408*^9, {3.941518418753319*^9, 3.941518436017467*^9}, + 3.941518506514503*^9, 3.9415186678213663`*^9, 3.94151878816772*^9, + 3.941518930271064*^9, 3.941524789151843*^9, 3.941525052529055*^9, + 3.941525223263277*^9, 3.941525310950933*^9, 3.9415257007103243`*^9, + 3.94152899981022*^9, 3.941531065665744*^9, 3.9415322221566772`*^9, + 3.941543605943892*^9, 3.9415439146525593`*^9, 3.941543993887024*^9, + 3.941545930879993*^9, 3.94162301201434*^9, 3.941623323243279*^9, + 3.980419544580164*^9, 3.980420976435289*^9, 3.980421442630149*^9, + 3.9804217996122704`*^9, 3.9804223560539*^9, 3.980423483943228*^9, + 3.980423570934939*^9, 3.9804323880265083`*^9, 3.980432889684306*^9, + 3.980434519150025*^9, 3.9804346457616987`*^9, 3.980434773645422*^9, + 3.980435031800393*^9, 3.982830187261292*^9, 3.982831363420928*^9, + 3.9828314519018393`*^9, 3.982852024070077*^9, 3.982852257490657*^9, + 3.9828527873122396`*^9}, + CellLabel->"Out[8]=",ExpressionUUID->"09638d36-e084-4afc-bc77-821a997aa418"], + +Cell["\<\ +1. - 0.5*Cos(0.5 - yl)* + Sin(31.41592653589794*(-0.4 + xl))* + Sin(0.1 - 4*zl)\ +\>", "Output", + CellChangeTimes->{ + 3.941009688547415*^9, 3.941091609619776*^9, {3.941091721815781*^9, + 3.94109175661007*^9}, 3.941091800122217*^9, 3.941091861807825*^9, + 3.941094505048383*^9, 3.941094632399669*^9, 3.94109500239986*^9, + 3.941106598058303*^9, 3.94110669394636*^9, 3.941106733977233*^9, + 3.9411070572842493`*^9, 3.941108055401798*^9, 3.941110920195258*^9, + 3.941111135388945*^9, 3.9411154343472643`*^9, 3.941120680145395*^9, + 3.941120754512067*^9, 3.941120792306068*^9, 3.941125270776736*^9, + 3.9411285314437933`*^9, 3.94112865354068*^9, 3.9411305706981773`*^9, + 3.941130863732583*^9, 3.941131412892272*^9, 3.941132715845481*^9, + 3.941133367217663*^9, 3.94113549000552*^9, 3.9412642619733667`*^9, + 3.941264321927586*^9, 3.941266776146008*^9, 3.941269726592196*^9, + 3.9412704321241703`*^9, 3.941271127788968*^9, 3.941271764441196*^9, + 3.941271938828134*^9, 3.941272048248835*^9, 3.9412730959363823`*^9, + 3.941273591507408*^9, {3.941518418753319*^9, 3.941518436017467*^9}, + 3.941518506514503*^9, 3.9415186678213663`*^9, 3.94151878816772*^9, + 3.941518930271064*^9, 3.941524789151843*^9, 3.941525052529055*^9, + 3.941525223263277*^9, 3.941525310950933*^9, 3.9415257007103243`*^9, + 3.94152899981022*^9, 3.941531065665744*^9, 3.9415322221566772`*^9, + 3.941543605943892*^9, 3.9415439146525593`*^9, 3.941543993887024*^9, + 3.941545930879993*^9, 3.94162301201434*^9, 3.941623323243279*^9, + 3.980419544580164*^9, 3.980420976435289*^9, 3.980421442630149*^9, + 3.9804217996122704`*^9, 3.9804223560539*^9, 3.980423483943228*^9, + 3.980423570934939*^9, 3.9804323880265083`*^9, 3.980432889684306*^9, + 3.980434519150025*^9, 3.9804346457616987`*^9, 3.980434773645422*^9, + 3.980435031800393*^9, 3.982830187261292*^9, 3.982831363420928*^9, + 3.9828314519018393`*^9, 3.982852024070077*^9, 3.982852257490657*^9, + 3.9828527873668756`*^9}, + CellLabel-> + "Out[17]//CForm=",ExpressionUUID->"fe74f41e-c333-4ebc-97bc-a1af72f7317e"] +}, Open ]], + +Cell[BoxData[""], "Input", + CellChangeTimes->{{3.9804234827382107`*^9, 3.980423485860519*^9}}, + CellLabel->"In[18]:=",ExpressionUUID->"0c455491-396e-4fa5-bafb-c4d65177fdbe"], + +Cell[BoxData[ + RowBox[{ + RowBox[{"Export", "[", + RowBox[{ + RowBox[{"FileNameJoin", "[", + RowBox[{"{", + RowBox[{ + RowBox[{"NotebookDirectory", "[", "]"}], ",", "\"\\""}], + "}"}], "]"}], ",", + RowBox[{"ToLowerCase", "[", + RowBox[{"ToString", "[", + RowBox[{ + RowBox[{"CForm", "[", + RowBox[{"MmsDens", "[", + RowBox[{"xl", ",", "zl", ",", "yl", ",", "t"}], "]"}], "]"}], ",", + "InputForm"}], "]"}], "]"}]}], "]"}], ";"}]], "Input", + CellChangeTimes->{{3.941091108047451*^9, 3.941091108047735*^9}, + 3.941091893938613*^9, {3.941091943764895*^9, 3.941091953659176*^9}, { + 3.94109205520127*^9, 3.9410920828692217`*^9}, {3.941543505174944*^9, + 3.941543506958555*^9}, {3.941551089773295*^9, 3.941551093286003*^9}, { + 3.9804213870984488`*^9, 3.980421390947422*^9}, {3.9804222978401527`*^9, + 3.980422306130024*^9}}, + CellLabel->"In[19]:=",ExpressionUUID->"cd5ebc8a-fccb-4775-844a-8c1ba286b63e"], + +Cell[BoxData[ + RowBox[{ + RowBox[{"Export", "[", + RowBox[{ + RowBox[{"FileNameJoin", "[", + RowBox[{"{", + RowBox[{ + RowBox[{"NotebookDirectory", "[", "]"}], ",", "\"\\""}], + "}"}], "]"}], ",", + RowBox[{"ToLowerCase", "[", + RowBox[{"ToString", "[", + RowBox[{ + RowBox[{"CForm", "[", + RowBox[{"Smms", "[", + RowBox[{"xl", ",", "zl", ",", "yl", ",", "t"}], "]"}], "]"}], ",", + "InputForm"}], "]"}], "]"}]}], "]"}], ";"}]], "Input", + CellChangeTimes->{{3.941092152330538*^9, 3.941092164437331*^9}, { + 3.941543525003409*^9, 3.9415435486676207`*^9}, {3.94155108160419*^9, + 3.941551083792343*^9}, {3.9804213936372538`*^9, 3.980421397635703*^9}, { + 3.980422311434009*^9, 3.980422315912444*^9}}, + CellLabel->"In[20]:=",ExpressionUUID->"7cc82ed0-d87d-45ee-84ec-f81154fbf211"] +}, +WindowSize->{513, 627}, +WindowMargins->{{Automatic, 0}, {Automatic, 0}}, +FrontEndVersion->"14.3 for Linux x86 (64-bit) (July 8, 2025)", +StyleDefinitions->"Default.nb", +ExpressionUUID->"ee53c5d0-dbab-4b20-a961-e0f5716cf87c" +] +(* End of Notebook Content *) + +(* Internal cache information *) +(*CellTagsOutline +CellTagsIndex->{} +*) +(*CellTagsIndex +CellTagsIndex->{} +*) +(*NotebookFileOutline +Notebook[{ +Cell[CellGroupData[{ +Cell[580, 22, 285, 5, 51, "Input",ExpressionUUID->"a48e709c-4f46-4e32-b340-a589ee6f1552"], +Cell[868, 29, 817, 14, 53, "Output",ExpressionUUID->"0e0ce5db-9968-4678-bade-a56ea533da98"] +}, Open ]], +Cell[CellGroupData[{ +Cell[1722, 48, 319, 5, 29, "Input",ExpressionUUID->"9f707231-815c-446a-a783-4c26634eb7ef"], +Cell[CellGroupData[{ +Cell[2066, 57, 766, 15, 23, "Print",ExpressionUUID->"473cff57-8647-4b4c-bf0c-4d5eaa3b6b82"], +Cell[2835, 74, 785, 15, 23, "Print",ExpressionUUID->"f5b098b0-d445-4178-844e-9ad69a9178f4"], +Cell[3623, 91, 780, 15, 30, "Print",ExpressionUUID->"3f9194e7-81e0-4b9d-9d98-51875d993cd6"] +}, Open ]] +}, Open ]], +Cell[CellGroupData[{ +Cell[4452, 112, 4255, 76, 374, "Input",ExpressionUUID->"595ab9b8-3e80-4f0d-9d22-14a98dc670e3"], +Cell[8710, 190, 2000, 29, 33, "Output",ExpressionUUID->"09638d36-e084-4afc-bc77-821a997aa418"], +Cell[10713, 221, 2089, 34, 80, "Output",ExpressionUUID->"fe74f41e-c333-4ebc-97bc-a1af72f7317e"] +}, Open ]], +Cell[12817, 258, 173, 2, 29, "Input",ExpressionUUID->"0c455491-396e-4fa5-bafb-c4d65177fdbe"], +Cell[12993, 262, 984, 22, 97, "Input",ExpressionUUID->"cd5ebc8a-fccb-4775-844a-8c1ba286b63e"], +Cell[13980, 286, 852, 20, 97, "Input",ExpressionUUID->"7cc82ed0-d87d-45ee-84ec-f81154fbf211"] +} +] +*) + diff --git a/tests/integrated/2D-axial-circular-fci/data/BOUT.inp b/tests/integrated/2D-axial-circular-fci/data/BOUT.inp new file mode 100644 index 000000000..cab67fc7a --- /dev/null +++ b/tests/integrated/2D-axial-circular-fci/data/BOUT.inp @@ -0,0 +1,67 @@ +nout = 50 +timestep = 0.1 + + + + + +minvalue= (-2.0+0.5) / (nx - 2*2) +maxvalue= (nx-3+0.5) / (nx - 2*2) +xmax = 0.6 +xmin = 0.4 +xl = (xmax - xmin)*(x-minvalue)/(maxvalue-minvalue) + xmin +yl = y +zl = z + + +[input] + +error_on_unused_options = false + +[mesh] + +extrapolate_y = false + +[mesh:paralleltransform] +type = fci + +[mesh] + +symmetricGlobalX = true + +[solver] +mxstep = 10000 +rtol = 1e-6 +atol = 1e-12 +mms = true # Run with MMS sources and output diagnostics +mms_initialise = true +type = cvode + + +[hermes] +components = h+ + + +Nnorm = 1e18 +Bnorm = 1 +Tnorm = 5 + +[h+] # Ions +type = evolve_density, anomalous_diffusion_3d +charge = 1.0 +AA = 1.0 + +mms = true + +anomalous_D = 1.0 +anomalous_D_par = 2000 + +use_finite_difference = true + +[Nh+] + +solution = 1. - 0.5*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl) + +source = (-0.000020877633788978686*(1.3333333333333333*cos(0.1 - 4*zl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.5 - yl) + 1.3888888888888888*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)))/(1 + 0.1111111111111111*power(xl,2)) - 1.0438816894489344e-8*((-15.70796326794897*cos(31.41592653589794*(-0.4 + xl))*cos(0.5 - yl)*sin(0.1 - 4*zl))/xl + 493.4802200544682*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl) + (8.*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl))/power(xl,2)) + +bndry_all = dirichlet_o2(`Nh+:solution`) diff --git a/tests/integrated/2D-axial-circular-fci/runtest b/tests/integrated/2D-axial-circular-fci/runtest new file mode 100755 index 000000000..cae56249c --- /dev/null +++ b/tests/integrated/2D-axial-circular-fci/runtest @@ -0,0 +1,135 @@ +#!/usr/bin/env python3 + +# Python script to run and analyse MMS test + +from __future__ import division +from __future__ import print_function +import numpy as np +try: + from builtins import str +except: + pass + +from boututils.run_wrapper import shell, launch_safe, getmpirun +from boutdata.collect import collect + +from numpy import sqrt, max, abs, mean, array, log, concatenate + +import tarfile + + +gridpath = "../../../../grids/mms_axial_circular_fci/" +#archive_path = "MMS_Circle_fci_XZ.tar.xz" + +#try: +# with tarfile.open(gridpath + archive_path, "r:xz") as tar: +# tar.extractall(path=gridpath) +# print("Successfully extracted the grids!") +#except: +# raise FileNotFoundError("Could not fine mms slab y file to extract") + + +#def gridname(nx): +# return gridpath + f"circular_{int(nx+4)}_{4}_{int(nx*8)}.nc" + +def gridname(nx): + return gridpath + f"Axial_circular_q_{int(nx)}_{int(4*nx)}_0.4_0.6_3.0_0.0.fci.grid.nc" + + +# List of NY values to use +#nxlist = [36, 68, 132, 260] #, 640, 1280, 2560, 5120] +nxlist = [16,32] +nout = 10 +timestep = 1e5 / nout + +nproc = 1 + +varnames = ["Nh+"] + +results = {} +for var in varnames: + results[var] = {"l2":[], "inf":[]} + +for ny in nxlist: + args = "mesh:file="+gridname(ny)+" nout="+str(nout)+" timestep="+str(timestep) + " nx="+str(ny+4) + + print("Running with " + args) + + # Delete old data + shell("rm data/BOUT.dmp.*.nc") + + # Command to run + cmd = "../../../hermes-3 " + args + # Launch using MPI + s, out = launch_safe(cmd, nproc=nproc, pipe=True) + + # Save output to log file + f = open("run.log."+str(ny), "w") + f.write(out) + f.close() + + # Collect data + for var in varnames: + E = collect("E_"+var, tind=[nout,nout], path="data", info=False) + print(str(np.array(E).shape)) + E = E[0,2:-2,1:-1,:] + + l2 = sqrt(mean(E**2)) + linf = max(abs(E)) + results[var]["l2"].append( l2 ) + results[var]["inf"].append( linf ) + + print("Error norm %s: l-2 %f l-inf %f" % (var, l2, linf)) + +# Calculate grid spacing +dy = 1. / array(nxlist) + +success = True + +for var in varnames: + l2 = results[var]["l2"] + order = log(l2[-1] / l2[-2]) / log(dy[-1] / dy[-2]) + print("Convergence order %s = %f" % (var, order)) + + if order < 1.8: + success = False + +# plot errors +try: + import matplotlib.pyplot as plt + + for var in varnames: + l2 = results[var]["l2"] + inf = results[var]["inf"] + order = log(l2[-1] / l2[-2]) / log(dy[-1] / dy[-2]) + + plt.plot(dy, l2, '-o', label=r'$l_2$ ('+var+')') + plt.plot(dy, inf, '-x', label=r'$l_\infty$ ('+var+')') + plt.plot(dy, l2[-1]*(dy/dy[-1])**order, '--', label="Order %.1f" % (order)) + + plt.legend(loc="upper left") + plt.grid() + + plt.yscale('log') + plt.xscale('log') + + plt.xlabel(r'Mesh spacing $\delta y$') + plt.ylabel("Error norm") + + plt.savefig("fluid_norm.pdf") + plt.savefig("fluid_norm.png") + + #plt.show() + plt.close() +except: + # Plotting could fail for any number of reasons, and the actual + # error raised may depend on, among other things, the current + # matplotlib backend, so catch everything + pass + +if success: + print(" => Test passed") + exit(0) +else: + print(" => Test failed") + exit(1) diff --git a/tests/integrated/3D-Axial-circular-conduction-fci/axial.m b/tests/integrated/3D-Axial-circular-conduction-fci/axial.m new file mode 100644 index 000000000..ba329ac96 --- /dev/null +++ b/tests/integrated/3D-Axial-circular-conduction-fci/axial.m @@ -0,0 +1,88 @@ +(* ::Package:: *) + +BeginPackage["axial`"] + +(* To run the package, execute the following line in a notebook +<Normal*) + +(* Beginning of Notebook Content *) +Notebook[{ + +Cell[CellGroupData[{ +Cell[BoxData[ + RowBox[{"\[IndentingNewLine]", + RowBox[{"SetDirectory", "[", + RowBox[{"NotebookDirectory", "[", "]"}], "]"}]}]], "Input", + CellChangeTimes->{{3.941091023755059*^9, 3.941091026844414*^9}}, + CellLabel->"In[1]:=",ExpressionUUID->"a48e709c-4f46-4e32-b340-a589ee6f1552"], + +Cell[BoxData["\<\"/viper/u1/toto/soft/hermes-3/build/tests/integrated/3D-\ +Axial-circular-conduction-fci\"\>"], "Output", + CellChangeTimes->CompressedData[" +1:eJwVy01IkwEAxvHVYc21ZJuSzW3RFzY7JEGDMah4O0iIiomGQfOLpFQoa6Ss +Q4qiRo5sI4UFYRRLl7M2ZlJBFlnqlpmYO2hLhdEO5jtCYU206HkOf36n//7q +q8U12yQSyRk0rXy+ILOIwrqqcl8KvBarcMlh3vjsJP0SjFxXwgujBV6qGp/J +VsGbmdvvqeG75qxBevmK42M6fG08VZIBe41tFnpWJnVqYPRWT7YWGuR/TXQ2 +t8+gg4vWgwXUe2nVQfMqpo7rYVXc3EF3yK3de2GRTdlggRenbE20wz/hKYe/ +Bk3aSjg9Um2lq8ubQfr18aSmCs4MZebQvkbzCVq/fu49/e079I/u2bj9dB7K +9D0jVOcxBqn+zQ13BJa2Rz/R+BP5d2o39cdoofg54wd8luULLMJGU+TlEhx+ +WJO7DDs3usM/4Zq7VhqDZQMNSbq2EnmgKBcFxUTKB2oXCs2KAfwBnUiVlpbD +u2Cx5mgJddYHXPSurfVYKowv9DerYZP6yChNdkrvpEG7PuSi5+veemhySxui +W72+fLdXFE5/cyzR9AOJFdplqE28gHP2rjQffOUfK6Ut87vHEjDUftL0B97f +GXcqhkShNVrkp5v5ZWH6KFzXlgr/A+x4JzQ= + "], + CellLabel->"Out[1]=",ExpressionUUID->"27a5f241-d41f-49cc-8b6a-b8b248eb2116"] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[ + RowBox[{"<<", "axial.m"}]], "Input", + CellChangeTimes->{{3.9410005336133223`*^9, 3.941000541398674*^9}, { + 3.941000701368867*^9, 3.941000721827975*^9}, {3.941000869088725*^9, + 3.941000881063511*^9}, 3.941091017550275*^9}, + CellLabel->"In[2]:=",ExpressionUUID->"9f707231-815c-446a-a783-4c26634eb7ef"], + +Cell[CellGroupData[{ + +Cell[BoxData["\<\"Computing MMS Terms\"\>"], "Print", + CellChangeTimes->CompressedData[" +1:eJwVzFtIUwEcx/GTqOmYZzpvlebIhJwPKpGhQ83zoiIMhoikuKMVITRNcWEI +e1hTam6BNUG8wITwMtQ5haZGNIaK2Ql8CCdJOsVrMY5gDzNcRv/fw5fP2/fG +w5bKx5cYhimlBsKihyRakQvf7xKgqsanjyVtBxlOyLCNWXHkbkTPGzkpTpon +oaE1sJwAD8arksnS7DAe1h432a6SbdaQMoUUjHUFUP81RplKZrLv1PD8FWeD +EX5F3nXynq/vJYxS/OpJIxc6O1q15Jou+BwmjbRP8OSttb6UBrLFPqOHCUGd +AJ+N5F57QIbkn3Ngyf2xIvi7e9oLTRWOf3DdXji+SX4zu+ehPe/TF7goHI5u +kR/uulZg7OWPP+ATTfExDKznXNkm08yW935SctMxt0PWXxSV7eL7ImPjkLT8 +PIo8Ijf2Q39guds9JOVFLl2/twjL8xdUUofI1RUOiFDLR2bGkMZmZxVUd90Z +hH+jZLdZUhWXapSTJoPHA59KDJZ4klU8GoSvz6snoFXzVoBOv0w9OiVy3uTv +O7D4oiwAE2VC0EWeJJ3Gz5DWyqxqaDDploKkZ7Uj/4xc5TW9UqfIdTcMz0Km +3+WDc0pvJ0v+B1jNGds= + "], + CellLabel-> + "During evaluation of \ +In[2]:=",ExpressionUUID->"ee153324-c97e-4280-bed4-3e2c1ef6ccca"], + +Cell[BoxData["\<\"Finished MMS Terms\"\>"], "Print", + CellChangeTimes->CompressedData[" +1:eJwVzF1IUwEchvGTpK0xz3TazI8cpZB6kREaNtQ8NyrBYMiQCneyJAJXKU0M +YRdrSu1D0CZIKiwIzaGtKbQypGEWZSfwQtwo1Cn5sWScIC9OsmX0fy8efnfP +yRttDTcPMQxTSw0lHR2RG0Xu8GaPALVXQuY00r1V6IMMe6skndxI7utXkeKk +fRJa2mMfM+HWuCGLrD2TxMOr0dvubPKeK1GcSwrWpgvQ/DW1OI8sYp/pYPwR +54bJEU35CfJiaPAhlGl2+/LJme6udiO5aJLuQ/Vo5wRPnl4czG0m2zxTZpgp +mQTYMXo25zqZUH0uhTWXn1fBPcfLOWi75P0Hlz2V49/JJXvgDfSUv/sC54Xt +sVXy7Xn/J5h2ZHYFtuqrozC2XHp8jcy3O19FSHmB9/U6ee2gqm4D3weF4W3S ++XMnZYcMbyb2YX0gMKLgRe6U+cc8rK+Y0Sq8ItdUOSRCI59SlEpa7/gMUNdT +Ngz/ypTnWFKbnmdVkTZLMAjvyi3ODJLVtAzD3njjBHTpHwvQF1Hqxl6I3FzW +t3VYfVAXg8eUguQnf6l/Z0yRroaSRmixmT5IZHChq+IPucDrBxQ+kXM0P52G +zBN/CBqk990s+R9bXhpH + "], + CellLabel-> + "During evaluation of \ +In[2]:=",ExpressionUUID->"fae6fdea-629c-4f55-b870-4501123a3e0b"], + +Cell[BoxData[ + RowBox[{"9.579629665962438`*^7", " ", "Bnorm"}]], "Print", + CellChangeTimes->CompressedData[" +1:eJwVzF1IUwEchvGjpM0xz3SampqjEvy40BAVG2qdG5VgMETExB2tCKFZigtF +2MWcUnMT1AWSCgtCc2lrE1oa0RAVsxN4EU4MdUp+JeMIdbHCqfh/Lx5+d8/V ++82VD8MYhimjhsKjRqRakbuw0y1A1V2fPoa07aY7IcM2ZseS2xF9/QpSnDRP +QkNLYCEe7o5XJZJlOeE8rD1osl0mW62hrBRSMNbdhPrv0VmpZCb7Wg2Pn3M2 +GOFXFlwhb/kGn0GJ8rAvjZzp6mjRksu6YDtMGG2b4MmM5cGUBrLZ7tbD+KBO +gE9HbyTfI0OKr7nwds2bEvi35/0sNN1xnMEVe/H4T/KH2TMN7QVfvsE5YW9s +g/xU6FqEMRc/r8NHmtIDGFjJTdok08yWD35Set3xcYusPy0p38a3M311j7T8 +3o/cJ1d3Qv9hhcczIuNF7pr+1xysKJpRyRwiV1c8JEItH5kZTRofO6ugujt/ +GJ5I5HksqYpNNSpIk8HrhU+kBkscySofDMPe4+oJaNUMCNDpl6vH3oncbOLa +Fiw9LQ/AS3Ih6CKPEv7EuUlrZXY1NJh080HSu9RR9I9c4jUvZE6R62l4NQWZ +ly4flLxd6GLJc1b1GbE= + "], + CellLabel-> + "During evaluation of \ +In[2]:=",ExpressionUUID->"882e0d34-442a-4d04-8521-72d08310709b"] +}, Open ]] +}, Open ]], + +Cell[CellGroupData[{ + +Cell[BoxData[{ + RowBox[{ + RowBox[{"Tnorm", " ", "=", " ", "5.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Nnorm", " ", "=", " ", + RowBox[{"10", "^", "18"}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Bnorm", " ", "=", " ", "1.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"AA", " ", "=", " ", + RowBox[{"1.0", "/", "1836.0"}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"kx", " ", "=", "1.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"kz", "=", "4"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"ky", "=", "1"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"omega", "=", "0.1"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Tamp", "=", "0.1"}], ";"}], "\[IndentingNewLine]", + RowBox[{"phz", " ", "=", " ", "0.1"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"phy", " ", "=", "0.5"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"pht", "=", " ", "0.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"xmin", "=", "0.4"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"xmax", "=", "0.6"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"T0", " ", "=", " ", "5.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"N0", " ", "=", " ", + RowBox[{"10", "^", "19"}]}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Chiperp", " ", "=", " ", "0.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"Chipar", " ", "=", " ", "0.0"}], ";"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{ + RowBox[{ + RowBox[{"q", "[", "x_", "]"}], " ", "=", " ", + RowBox[{"3.0", "+", + RowBox[{"0.0", " ", "*", " ", "x"}]}]}], ";"}], + "\[IndentingNewLine]"}], "\[IndentingNewLine]", + RowBox[{ + RowBox[{"CForm", "[", + RowBox[{"MmsP", "[", + RowBox[{"xl", ",", "zl", ",", "yl", ",", "t"}], "]"}], "]"}], + "\[IndentingNewLine]"}], "\[IndentingNewLine]"}], "Input", + CellChangeTimes->{{3.941001710751292*^9, 3.941001799493569*^9}, { + 3.94100196287262*^9, 3.94100197699585*^9}, {3.941002082278537*^9, + 3.941002091026224*^9}, {3.941005604446062*^9, 3.9410056280492363`*^9}, { + 3.941005702954153*^9, 3.941005712874386*^9}, {3.941005747843405*^9, + 3.94100575324975*^9}, {3.941009187354603*^9, 3.941009247364457*^9}, { + 3.94100966318116*^9, 3.941009680024501*^9}, {3.941091600565372*^9, + 3.9410916014166613`*^9}, {3.941091731467869*^9, 3.941091794275579*^9}, { + 3.941091841698888*^9, 3.94109184990349*^9}, {3.94110656901536*^9, + 3.941106579582962*^9}, {3.941106650936283*^9, 3.94110669207623*^9}, + 3.941106732865182*^9, {3.941120562846257*^9, 3.941120568623769*^9}, { + 3.941120627216084*^9, 3.941120628259906*^9}, {3.941120719254148*^9, + 3.941120719910901*^9}, {3.941120781889386*^9, 3.941120787474683*^9}, { + 3.9411251832829638`*^9, 3.941125233701482*^9}, {3.941128545834157*^9, + 3.9411285503249607`*^9}, {3.9411285973137712`*^9, 3.941128604556089*^9}, { + 3.941130823020509*^9, 3.941130836706815*^9}, {3.941132669299409*^9, + 3.9411326822525787`*^9}, {3.9411333416570683`*^9, 3.941133341715454*^9}, { + 3.9411354363450203`*^9, 3.941135441093075*^9}, {3.941137102236459*^9, + 3.941137103929172*^9}, {3.941212667495749*^9, 3.9412126703613577`*^9}, { + 3.941264227933763*^9, 3.941264274028784*^9}, {3.941266728760947*^9, + 3.941266734322445*^9}, {3.941269687955462*^9, 3.9412696987061653`*^9}, { + 3.941271079546174*^9, 3.941271081196938*^9}, {3.9412719962761*^9, + 3.941271997015006*^9}, {3.9412730616699057`*^9, 3.941273066087247*^9}, { + 3.941273533132288*^9, 3.94127355265935*^9}, {3.941273899665763*^9, + 3.941273921460822*^9}, {3.9415184110422688`*^9, 3.9415184170689363`*^9}, { + 3.9415185124635487`*^9, 3.9415185185770617`*^9}, {3.9415188636598063`*^9, + 3.94151886756817*^9}, 3.9415321328707323`*^9, {3.9415427858429737`*^9, + 3.941542828000198*^9}, {3.941542872244955*^9, 3.941542873488117*^9}, { + 3.941543280452444*^9, 3.941543353814756*^9}, {3.941543921314495*^9, + 3.941543944142756*^9}, {3.94154588614583*^9, 3.941545886200872*^9}, { + 3.941551072132766*^9, 3.94155107423029*^9}, {3.941622928218151*^9, + 3.941622975931859*^9}, {3.9416232368015337`*^9, 3.941623242079863*^9}, { + 3.980418501299036*^9, 3.980418510848222*^9}, {3.980419223612973*^9, + 3.9804192259502373`*^9}, {3.980419424952941*^9, 3.9804194250073843`*^9}, { + 3.9804234906671753`*^9, 3.980423505726005*^9}, {3.980441355886915*^9, + 3.980441368363199*^9}, {3.982829754504801*^9, 3.982829782740342*^9}, { + 3.9828299614012003`*^9, 3.982829964662109*^9}, {3.982831344310981*^9, + 3.9828313473575497`*^9}, {3.98285198331588*^9, 3.982851984615147*^9}, { + 3.9828527440353117`*^9, 3.9828527456692553`*^9}, {3.9829961854197617`*^9, + 3.982996259211157*^9}, {3.982996290397106*^9, 3.98299631633951*^9}, { + 3.982996835891934*^9, 3.982996849912133*^9}, 3.982996879955332*^9, { + 3.982997208861528*^9, 3.982997216510427*^9}, {3.983042174356776*^9, + 3.9830421802111893`*^9}, {3.98304561106677*^9, 3.983045628709486*^9}}, + CellLabel->"In[3]:=",ExpressionUUID->"595ab9b8-3e80-4f0d-9d22-14a98dc670e3"], + +Cell[BoxData["0.1`"], "Output", + CellChangeTimes->{ + 3.941009688547415*^9, 3.941091609619776*^9, {3.941091721815781*^9, + 3.94109175661007*^9}, 3.941091800122217*^9, 3.941091861807825*^9, + 3.941094505048383*^9, 3.941094632399669*^9, 3.94109500239986*^9, + 3.941106598058303*^9, 3.94110669394636*^9, 3.941106733977233*^9, + 3.9411070572842493`*^9, 3.941108055401798*^9, 3.941110920195258*^9, + 3.941111135388945*^9, 3.9411154343472643`*^9, 3.941120680145395*^9, + 3.941120754512067*^9, 3.941120792306068*^9, 3.941125270776736*^9, + 3.9411285314437933`*^9, 3.94112865354068*^9, 3.9411305706981773`*^9, + 3.941130863732583*^9, 3.941131412892272*^9, 3.941132715845481*^9, + 3.941133367217663*^9, 3.94113549000552*^9, 3.9412642619733667`*^9, + 3.941264321927586*^9, 3.941266776146008*^9, 3.941269726592196*^9, + 3.9412704321241703`*^9, 3.941271127788968*^9, 3.941271764441196*^9, + 3.941271938828134*^9, 3.941272048248835*^9, 3.9412730959363823`*^9, + 3.941273591507408*^9, {3.941518418753319*^9, 3.941518436017467*^9}, + 3.941518506514503*^9, 3.9415186678213663`*^9, 3.94151878816772*^9, + 3.941518930271064*^9, 3.941524789151843*^9, 3.941525052529055*^9, + 3.941525223263277*^9, 3.941525310950933*^9, 3.9415257007103243`*^9, + 3.94152899981022*^9, 3.941531065665744*^9, 3.9415322221566772`*^9, + 3.941543605943892*^9, 3.9415439146525593`*^9, 3.941543993887024*^9, + 3.941545930879993*^9, 3.94162301201434*^9, 3.941623323243279*^9, + 3.980419544580164*^9, 3.980420976435289*^9, 3.980421442630149*^9, + 3.9804217996122704`*^9, 3.9804223560539*^9, 3.980423483943228*^9, + 3.980423570934939*^9, 3.9804323880265083`*^9, 3.980432889684306*^9, + 3.980434519150025*^9, 3.9804346457616987`*^9, 3.980434773645422*^9, + 3.980435031800393*^9, 3.982830187261292*^9, 3.982831363420928*^9, + 3.9828314519018393`*^9, 3.982852024070077*^9, 3.982852257490657*^9, + 3.9828527873122396`*^9, 3.9829970217485867`*^9, 3.982997958253395*^9, + 3.983041693006072*^9, 3.983041935188232*^9, 3.983042223678401*^9, + 3.9830456641790857`*^9}, + CellLabel->"Out[12]=",ExpressionUUID->"baae0d55-cf15-4553-b79e-331e2afe970e"], + +Cell["\<\ +2.*(5. - 0.1*Cos(0.5 - yl)* + Sin(31.41592653589794*(-0.4 + xl))* + Sin(0.1 - 4*zl))\ +\>", "Output", + CellChangeTimes->{ + 3.941009688547415*^9, 3.941091609619776*^9, {3.941091721815781*^9, + 3.94109175661007*^9}, 3.941091800122217*^9, 3.941091861807825*^9, + 3.941094505048383*^9, 3.941094632399669*^9, 3.94109500239986*^9, + 3.941106598058303*^9, 3.94110669394636*^9, 3.941106733977233*^9, + 3.9411070572842493`*^9, 3.941108055401798*^9, 3.941110920195258*^9, + 3.941111135388945*^9, 3.9411154343472643`*^9, 3.941120680145395*^9, + 3.941120754512067*^9, 3.941120792306068*^9, 3.941125270776736*^9, + 3.9411285314437933`*^9, 3.94112865354068*^9, 3.9411305706981773`*^9, + 3.941130863732583*^9, 3.941131412892272*^9, 3.941132715845481*^9, + 3.941133367217663*^9, 3.94113549000552*^9, 3.9412642619733667`*^9, + 3.941264321927586*^9, 3.941266776146008*^9, 3.941269726592196*^9, + 3.9412704321241703`*^9, 3.941271127788968*^9, 3.941271764441196*^9, + 3.941271938828134*^9, 3.941272048248835*^9, 3.9412730959363823`*^9, + 3.941273591507408*^9, {3.941518418753319*^9, 3.941518436017467*^9}, + 3.941518506514503*^9, 3.9415186678213663`*^9, 3.94151878816772*^9, + 3.941518930271064*^9, 3.941524789151843*^9, 3.941525052529055*^9, + 3.941525223263277*^9, 3.941525310950933*^9, 3.9415257007103243`*^9, + 3.94152899981022*^9, 3.941531065665744*^9, 3.9415322221566772`*^9, + 3.941543605943892*^9, 3.9415439146525593`*^9, 3.941543993887024*^9, + 3.941545930879993*^9, 3.94162301201434*^9, 3.941623323243279*^9, + 3.980419544580164*^9, 3.980420976435289*^9, 3.980421442630149*^9, + 3.9804217996122704`*^9, 3.9804223560539*^9, 3.980423483943228*^9, + 3.980423570934939*^9, 3.9804323880265083`*^9, 3.980432889684306*^9, + 3.980434519150025*^9, 3.9804346457616987`*^9, 3.980434773645422*^9, + 3.980435031800393*^9, 3.982830187261292*^9, 3.982831363420928*^9, + 3.9828314519018393`*^9, 3.982852024070077*^9, 3.982852257490657*^9, + 3.9828527873122396`*^9, 3.9829970217485867`*^9, 3.982997958253395*^9, + 3.983041693006072*^9, 3.983041935188232*^9, 3.983042223678401*^9, + 3.983045664235873*^9}, + CellLabel-> + "Out[22]//CForm=",ExpressionUUID->"b2eb15f6-30a9-4f3f-84e6-81ed416fedbc"] +}, Open ]], + +Cell[BoxData[""], "Input", + CellChangeTimes->{{3.9804234827382107`*^9, 3.980423485860519*^9}}, + CellLabel->"In[23]:=",ExpressionUUID->"0c455491-396e-4fa5-bafb-c4d65177fdbe"], + +Cell[BoxData[ + RowBox[{ + RowBox[{"Export", "[", + RowBox[{ + RowBox[{"FileNameJoin", "[", + RowBox[{"{", + RowBox[{ + RowBox[{"NotebookDirectory", "[", "]"}], ",", "\"\\""}], + "}"}], "]"}], ",", + RowBox[{"ToLowerCase", "[", + RowBox[{"ToString", "[", + RowBox[{ + RowBox[{"CForm", "[", + RowBox[{"MmsP", "[", + RowBox[{"xl", ",", "zl", ",", "yl", ",", "t"}], "]"}], "]"}], ",", + "InputForm"}], "]"}], "]"}]}], "]"}], ";"}]], "Input", + CellChangeTimes->{{3.941091108047451*^9, 3.941091108047735*^9}, + 3.941091893938613*^9, {3.941091943764895*^9, 3.941091953659176*^9}, { + 3.94109205520127*^9, 3.9410920828692217`*^9}, {3.941543505174944*^9, + 3.941543506958555*^9}, {3.941551089773295*^9, 3.941551093286003*^9}, { + 3.9804213870984488`*^9, 3.980421390947422*^9}, {3.9804222978401527`*^9, + 3.980422306130024*^9}, 3.982996996609498*^9}, + CellLabel->"In[24]:=",ExpressionUUID->"cd5ebc8a-fccb-4775-844a-8c1ba286b63e"], + +Cell[BoxData[ + RowBox[{ + RowBox[{"Export", "[", + RowBox[{ + RowBox[{"FileNameJoin", "[", + RowBox[{"{", + RowBox[{ + RowBox[{"NotebookDirectory", "[", "]"}], ",", "\"\\""}], + "}"}], "]"}], ",", + RowBox[{"ToLowerCase", "[", + RowBox[{"ToString", "[", + RowBox[{ + RowBox[{"CForm", "[", + RowBox[{"Smms", "[", + RowBox[{"xl", ",", "zl", ",", "yl", ",", "t"}], "]"}], "]"}], ",", + "InputForm"}], "]"}], "]"}]}], "]"}], ";"}]], "Input", + CellChangeTimes->{{3.941092152330538*^9, 3.941092164437331*^9}, { + 3.941543525003409*^9, 3.9415435486676207`*^9}, {3.94155108160419*^9, + 3.941551083792343*^9}, {3.9804213936372538`*^9, 3.980421397635703*^9}, { + 3.980422311434009*^9, 3.980422315912444*^9}}, + CellLabel->"In[25]:=",ExpressionUUID->"7cc82ed0-d87d-45ee-84ec-f81154fbf211"] +}, +WindowSize->{513, 627}, +WindowMargins->{{0, Automatic}, {Automatic, 0}}, +FrontEndVersion->"14.3 for Linux x86 (64-bit) (July 8, 2025)", +StyleDefinitions->"Default.nb", +ExpressionUUID->"ee53c5d0-dbab-4b20-a961-e0f5716cf87c" +] +(* End of Notebook Content *) + +(* Internal cache information *) +(*CellTagsOutline +CellTagsIndex->{} +*) +(*CellTagsIndex +CellTagsIndex->{} +*) +(*NotebookFileOutline +Notebook[{ +Cell[CellGroupData[{ +Cell[580, 22, 285, 5, 51, "Input",ExpressionUUID->"a48e709c-4f46-4e32-b340-a589ee6f1552"], +Cell[868, 29, 889, 15, 53, "Output",ExpressionUUID->"27a5f241-d41f-49cc-8b6a-b8b248eb2116"] +}, Open ]], +Cell[CellGroupData[{ +Cell[1794, 49, 319, 5, 29, "Input",ExpressionUUID->"9f707231-815c-446a-a783-4c26634eb7ef"], +Cell[CellGroupData[{ +Cell[2138, 58, 831, 16, 23, "Print",ExpressionUUID->"ee153324-c97e-4280-bed4-3e2c1ef6ccca"], +Cell[2972, 76, 830, 16, 23, "Print",ExpressionUUID->"fae6fdea-629c-4f55-b870-4501123a3e0b"], +Cell[3805, 94, 851, 17, 30, "Print",ExpressionUUID->"882e0d34-442a-4d04-8521-72d08310709b"] +}, Open ]] +}, Open ]], +Cell[CellGroupData[{ +Cell[4705, 117, 5059, 93, 476, "Input",ExpressionUUID->"595ab9b8-3e80-4f0d-9d22-14a98dc670e3"], +Cell[9767, 212, 2145, 31, 33, "Output",ExpressionUUID->"baae0d55-cf15-4553-b79e-331e2afe970e"], +Cell[11915, 245, 2240, 36, 80, "Output",ExpressionUUID->"b2eb15f6-30a9-4f3f-84e6-81ed416fedbc"] +}, Open ]], +Cell[14170, 284, 173, 2, 29, "Input",ExpressionUUID->"0c455491-396e-4fa5-bafb-c4d65177fdbe"], +Cell[14346, 288, 1003, 22, 97, "Input",ExpressionUUID->"cd5ebc8a-fccb-4775-844a-8c1ba286b63e"], +Cell[15352, 312, 852, 20, 97, "Input",ExpressionUUID->"7cc82ed0-d87d-45ee-84ec-f81154fbf211"] +} +] +*) + diff --git a/tests/integrated/3D-Axial-circular-conduction-fci/data/BOUT.inp b/tests/integrated/3D-Axial-circular-conduction-fci/data/BOUT.inp new file mode 100644 index 000000000..5f30feab3 --- /dev/null +++ b/tests/integrated/3D-Axial-circular-conduction-fci/data/BOUT.inp @@ -0,0 +1,99 @@ +nout = 50 +timestep = 0.1 + + + + + +minvalue= (-2.0+0.5) / (nx - 2*2) +maxvalue= (nx-3+0.5) / (nx - 2*2) +xmax = 0.6 +xmin = 0.4 +xl = (xmax - xmin)*(x-minvalue)/(maxvalue-minvalue) + xmin +yl = y +zl = z + + +[input] + +error_on_unused_options = false + +[mesh] + +extrapolate_y = false + +[mesh:paralleltransform] +type = fci + +[mesh] + +symmetricGlobalX = true + +[solver] +mxstep = 10000 +rtol = 1e-5 +atol = 1e-8 +mms = true # Run with MMS sources and output diagnostics +mms_initialise = true +type = cvode + + +[hermes] +components = e,collisions + + +Nnorm = 1e18 +Bnorm = 1 +Tnorm = 5 + +[e] # Ions +type = fixed_density, evolve_pressure +charge = -1.0 +AA = 1.0/1836.0 + +mms = true +density = 1e19 +thermal_conduction = true +use_finite_difference = false + +[Pe] + +solution = 2.*(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)) + +source = 0. - (3.479894918169595e-8*((38246.83553018219*power(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl),2.5)*(0.02666666666666 +667*cos(0.1 - 4*zl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.5 - yl) + 0.020000000000000004*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 +- 4*zl)))/(sqrt(1 + 0.1111111111111111*power(xl,2))*(8.525441616556563 - sqrt(0.00001 + 0.0625*power(-2. + log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653 +589794*(-0.4 + xl))*sin(0.1 - 4*zl)),2)) + 1.25*log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)))) - (9561.708882545547 +*sin(31.41592653589794*(-0.4 + xl))*sin(0.5 - yl)*sin(0.1 - 4*zl)*power(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl),1.5 +)*(0.02666666666666667*cos(0.5 - yl)*cos(0.1 - 4*zl)*sin(31.41592653589794*(-0.4 + xl)) - 0.020000000000000004*sin(31.41592653589794*(-0.4 + xl))*sin +(0.5 - yl)*sin(0.1 - 4*zl)))/(sqrt(1 + 0.1111111111111111*power(xl,2))*(8.525441616556563 - sqrt(0.00001 + 0.0625*power(-2. + log(5. - 0.1*cos(0.5 - +yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)),2)) + 1.25*log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)))) - + (38246.83553018219*power(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl),2.5)*(0.02666666666666667*cos(0.5 - yl)*cos(0.1 - + 4*zl)*sin(31.41592653589794*(-0.4 + xl)) - 0.020000000000000004*sin(31.41592653589794*(-0.4 + xl))*sin(0.5 - yl)*sin(0.1 - 4*zl))*((-0.125*sin(31.41 +592653589794*(-0.4 + xl))*sin(0.5 - yl)*sin(0.1 - 4*zl))/(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)) + (0.00625*(-2. ++ log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)))*sin(31.41592653589794*(-0.4 + xl))*sin(0.5 - yl)*sin(0.1 - 4*zl))/( +sqrt(0.00001 + 0.0625*power(-2. + log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)),2))*(5. - 0.1*cos(0.5 - yl)*sin(31.4 +1592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)))))/(sqrt(1 + 0.1111111111111111*power(xl,2))*power(8.525441616556563 - sqrt(0.00001 + 0.0625*power(-2. + +log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)),2)) + 1.25*log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl +))*sin(0.1 - 4*zl)),2)) + 0.3333333333333333*((38246.83553018219*power(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl),2.5) +*(0.08000000000000002*cos(0.1 - 4*zl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.5 - yl) + 0.10666666666666667*cos(0.5 - yl)*sin(31.41592653589794*(-0. +4 + xl))*sin(0.1 - 4*zl)))/(sqrt(1 + 0.1111111111111111*power(xl,2))*(8.525441616556563 - sqrt(0.00001 + 0.0625*power(-2. + log(5. - 0.1*cos(0.5 - yl +)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)),2)) + 1.25*log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)))) + ( +38246.83553018219*cos(0.5 - yl)*cos(0.1 - 4*zl)*sin(31.41592653589794*(-0.4 + xl))*power(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*si +n(0.1 - 4*zl),1.5)*(0.02666666666666667*cos(0.5 - yl)*cos(0.1 - 4*zl)*sin(31.41592653589794*(-0.4 + xl)) - 0.020000000000000004*sin(31.41592653589794 +*(-0.4 + xl))*sin(0.5 - yl)*sin(0.1 - 4*zl)))/(sqrt(1 + 0.1111111111111111*power(xl,2))*(8.525441616556563 - sqrt(0.00001 + 0.0625*power(-2. + log(5. + - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)),2)) + 1.25*log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin +(0.1 - 4*zl)))) - (38246.83553018219*power(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl),2.5)*(0.02666666666666667*cos(0. +5 - yl)*cos(0.1 - 4*zl)*sin(31.41592653589794*(-0.4 + xl)) - 0.020000000000000004*sin(31.41592653589794*(-0.4 + xl))*sin(0.5 - yl)*sin(0.1 - 4*zl))*( +(0.5*cos(0.5 - yl)*cos(0.1 - 4*zl)*sin(31.41592653589794*(-0.4 + xl)))/(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)) - +(0.025*cos(0.5 - yl)*cos(0.1 - 4*zl)*(-2. + log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)))*sin(31.41592653589794*(-0 +.4 + xl)))/(sqrt(0.00001 + 0.0625*power(-2. + log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)),2))*(5. - 0.1*cos(0.5 - +yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)))))/(sqrt(1 + 0.1111111111111111*power(xl,2))*power(8.525441616556563 - sqrt(0.00001 + 0.0625* +power(-2. + log(5. - 0.1*cos(0.5 - yl)*sin(31.41592653589794*(-0.4 + xl))*sin(0.1 - 4*zl)),2)) + 1.25*log(5. - 0.1*cos(0.5 - yl)*sin(31.4159265358979 +4*(-0.4 + xl))*sin(0.1 - 4*zl)),2)))))/sqrt(1 + 0.1111111111111111*power(xl,2)) + + + + + +bndry_all = dirichlet_o2(`Pe:solution`) diff --git a/tests/integrated/3D-Axial-circular-conduction-fci/runtest b/tests/integrated/3D-Axial-circular-conduction-fci/runtest new file mode 100755 index 000000000..fd80a6452 --- /dev/null +++ b/tests/integrated/3D-Axial-circular-conduction-fci/runtest @@ -0,0 +1,135 @@ +#!/usr/bin/env python3 + +# Python script to run and analyse MMS test + +from __future__ import division +from __future__ import print_function +import numpy as np +try: + from builtins import str +except: + pass + +from boututils.run_wrapper import shell, launch_safe, getmpirun +from boutdata.collect import collect + +from numpy import sqrt, max, abs, mean, array, log, concatenate + +import tarfile + + +gridpath = "../../../../grids/mms_axial_circular_fci/" +#archive_path = "MMS_Circle_fci_XZ.tar.xz" + +#try: +# with tarfile.open(gridpath + archive_path, "r:xz") as tar: +# tar.extractall(path=gridpath) +# print("Successfully extracted the grids!") +#except: +# raise FileNotFoundError("Could not fine mms slab y file to extract") + + +#def gridname(nx): +# return gridpath + f"circular_{int(nx+4)}_{4}_{int(nx*8)}.nc" + +def gridname(nx): + return gridpath + f"Axial_circular_q_{int(nx)}_{int(4*nx)}_0.4_0.6_3.0_0.0.fci.grid.nc" + + +# List of NY values to use +#nxlist = [36, 68, 132, 260] #, 640, 1280, 2560, 5120] +nxlist = [16,32] +nout = 10 +timestep = 1e4 / nout + +nproc = 1 + +varnames = ["Pe"] + +results = {} +for var in varnames: + results[var] = {"l2":[], "inf":[]} + +for ny in nxlist: + args = "mesh:file="+gridname(ny)+" nout="+str(nout)+" timestep="+str(timestep) + " nx="+str(ny+4) + + print("Running with " + args) + + # Delete old data + shell("rm data/BOUT.dmp.*.nc") + + # Command to run + cmd = "../../../hermes-3 " + args + # Launch using MPI + s, out = launch_safe(cmd, nproc=nproc, pipe=True) + + # Save output to log file + f = open("run.log."+str(ny), "w") + f.write(out) + f.close() + + # Collect data + for var in varnames: + E = collect("E_"+var, tind=[nout,nout], path="data", info=False) + print(str(np.array(E).shape)) + E = E[0,2:-2,1:-1,:] + + l2 = sqrt(mean(E**2)) + linf = max(abs(E)) + results[var]["l2"].append( l2 ) + results[var]["inf"].append( linf ) + + print("Error norm %s: l-2 %f l-inf %f" % (var, l2, linf)) + +# Calculate grid spacing +dy = 1. / array(nxlist) + +success = True + +for var in varnames: + l2 = results[var]["l2"] + order = log(l2[-1] / l2[-2]) / log(dy[-1] / dy[-2]) + print("Convergence order %s = %f" % (var, order)) + + if order < 1.8: + success = False + +# plot errors +try: + import matplotlib.pyplot as plt + + for var in varnames: + l2 = results[var]["l2"] + inf = results[var]["inf"] + order = log(l2[-1] / l2[-2]) / log(dy[-1] / dy[-2]) + + plt.plot(dy, l2, '-o', label=r'$l_2$ ('+var+')') + plt.plot(dy, inf, '-x', label=r'$l_\infty$ ('+var+')') + plt.plot(dy, l2[-1]*(dy/dy[-1])**order, '--', label="Order %.1f" % (order)) + + plt.legend(loc="upper left") + plt.grid() + + plt.yscale('log') + plt.xscale('log') + + plt.xlabel(r'Mesh spacing $\delta y$') + plt.ylabel("Error norm") + + plt.savefig("fluid_norm.pdf") + plt.savefig("fluid_norm.png") + + #plt.show() + plt.close() +except: + # Plotting could fail for any number of reasons, and the actual + # error raised may depend on, among other things, the current + # matplotlib backend, so catch everything + pass + +if success: + print(" => Test passed") + exit(0) +else: + print(" => Test failed") + exit(1)