From 0ad42a5cad060ec3594ac851543bb588249d78fb Mon Sep 17 00:00:00 2001 From: Chad Mitchell Date: Fri, 22 Nov 2024 09:56:38 -0800 Subject: [PATCH 1/3] Add simple benchmark for fftx. --- examples/benchmark_fftx/Ex_Mayes.dat | 202 +++++++++++++++++++ examples/benchmark_fftx/run_fieldplots_Ex.py | 184 +++++++++++++++++ 2 files changed, 386 insertions(+) create mode 100644 examples/benchmark_fftx/Ex_Mayes.dat create mode 100644 examples/benchmark_fftx/run_fieldplots_Ex.py diff --git a/examples/benchmark_fftx/Ex_Mayes.dat b/examples/benchmark_fftx/Ex_Mayes.dat new file mode 100644 index 000000000..f2c39be08 --- /dev/null +++ b/examples/benchmark_fftx/Ex_Mayes.dat @@ -0,0 +1,202 @@ +x/sigmax r=0.01 r=0.1 r=1 r=10 r=0.5 r=0.2 +-6. -0.261369493716395 -0.261237523631927 -0.249654197553638 -0.09976033376621 -0.258155010896897 -0.260840196815813 +-5.94 -0.266953674208605 -0.266815400081879 -0.254723181057423 -0.101010854014917 -0.263589852737481 -0.266399227678862 +-5.88 -0.272723128062216 -0.272578141476905 -0.259948124572655 -0.102287241804509 -0.269200817973769 -0.272141928944631 +-5.82 -0.278686408732781 -0.278534264724715 -0.26533549114963 -0.103590284765086 -0.274995738823736 -0.278076717669295 +-5.76 -0.284852591618508 -0.284692803936369 -0.270892081693457 -0.104920802900283 -0.280982896845394 -0.284212517041818 +-5.7 -0.291231315183612 -0.291063350682117 -0.27662505623096 -0.106279650261658 -0.287171054819377 -0.290558795033396 +-5.64 -0.297832826181772 -0.297656098152312 -0.282541956707611 -0.107667716723571 -0.293569491303868 -0.297125606667076 +-5.58 -0.304668029468551 -0.304481889665772 -0.288650731427132 -0.10908592986321 -0.300188038103393 -0.303923640294388 +-5.52 -0.311748542957857 -0.311552272023611 -0.29495976125277 -0.110535256953557 -0.307037120916026 -0.310964268310789 +-5.46 -0.319086758345141 -0.318879554261481 -0.301477887690525 -0.112016707071577 -0.314127803441033 -0.318259602784132 +-5.4 -0.326695908295686 -0.32647687241365 -0.308214442984485 -0.113531333328536 -0.321471835247027 -0.325822556516324 +-5.34 -0.334590140882672 -0.334358260970822 -0.315179282347658 -0.115080235226671 -0.329081703721572 -0.333666910110072 +-5.28 -0.342784602147875 -0.342538731780674 -0.322382818457214 -0.116664561143113 -0.336970690436887 -0.34180738566051 +-5.22 -0.351295527754455 -0.351034361212299 -0.329836058335435 -0.118285510945827 -0.345152932279572 -0.350259727741917 +-5.16 -0.360140344801548 -0.359862386477687 -0.337550642729865 -0.119944338738998 -0.353643487699854 -0.359040792407264 +-5.1 -0.369337784973051 -0.369041312073897 -0.345538888091861 -0.121642355735701 -0.362458408436666 -0.368168644961581 +-5.04 -0.378908010295167 -0.378591027375272 -0.353813831231502 -0.123380933251325 -0.371614817066699 -0.377662667306034 +-4.98 -0.388872752875012 -0.388532936462194 -0.362389276696976 -0.125161505806847 -0.381130990705433 -0.387543675674362 +-4.92 -0.399255470080714 -0.398890101316289 -0.37127984688606 -0.126985574325505 -0.391026451152862 -0.397834049592349 +-4.86 -0.410081516695406 -0.40968739953549 -0.380501034843946 -0.128854709399271 -0.401322061722229 -0.408557872878621 +-4.8 -0.421378335624961 -0.420951697718346 -0.390069259632906 -0.130770554592987 -0.412040130912185 -0.41974108746451 +-4.74 -0.43317566875222 -0.432712041626281 -0.400001924072191 -0.13273482974331 -0.423204522976121 -0.431411660734167 +-4.68 -0.445505789496515 -0.444999864144437 -0.410317474538181 -0.134749334196794 -0.434840775301475 -0.443599766964302 +-4.62 -0.458403758542152 -0.457849211913842 -0.421035462381539 -0.136815949916017 -0.446976222330087 -0.456337983265444 +-4.56 -0.471907704026378 -0.47129699128579 -0.432176606356655 -0.138936644364383 -0.459640125521418 -0.469661500181878 +-4.5 -0.486059127207212 -0.485383233937644 -0.443762855265095 -0.141113473058658 -0.472863808576468 -0.483608346782469 +-4.44 -0.500903234242991 -0.500151382070575 -0.455817449785611 -0.143348581653291 -0.48668079679385 -0.498219629655783 +-4.38 -0.516489294185473 -0.515648592565513 -0.46836498219488 -0.145644207391591 -0.501126959013664 -0.513539784695956 +-4.32 -0.532871023280858 -0.53192605871619 -0.481431452372396 -0.148002679725851 -0.516240650111513 -0.529616839848929 +-4.26 -0.550106989268224 -0.54903934784861 -0.495044318127313 -0.150426419871211 -0.532062851429066 -0.546502686733427 +-4.2 -0.568261047563319 -0.567048750195972 -0.509232537482513 -0.152917939016373 -0.548637305862097 -0.564253356251102 +-4.14 -0.587402781252272 -0.586019636967288 -0.524026600101693 -0.155479834868373 -0.566010643569943 -0.582929295923149 +-4.08 -0.607607963468264 -0.606022819337196 -0.539458544549109 -0.15811478615856 -0.584232493418817 -0.602595640765301 +-4.02 -0.628959020210432 -0.627134902213669 -0.555561957532726 -0.160825544683309 -0.603355574329254 -0.623322471789879 +-3.96 -0.65154548877234 -0.649438622830158 -0.572371950703606 -0.163614924396416 -0.62343575966923 -0.645185052740922 +-3.9 -0.675464458932848 -0.673023162620123 -0.589925109977838 -0.166485787011647 -0.644532106730759 -0.668264034413053 +-3.84 -0.700820981960204 -0.697984418419698 -0.60825941172144 -0.169441023514861 -0.666706842164933 -0.69264561390118 +-3.78 -0.727728429416803 -0.724425216513491 -0.627414099510064 -0.172483530927243 -0.690025293051141 -0.718421634067966 +-3.72 -0.756308780454608 -0.752455450361287 -0.647429514562855 -0.175616183606662 -0.714555752070589 -0.745689606371449 +-3.66 -0.786692812817072 -0.782192120075493 -0.66834687237715 -0.178841798325576 -0.740369264080279 -0.774552638017904 +-3.6 -0.819020169191834 -0.813759248934541 -0.690207977586379 -0.18216309232437 -0.767539320287618 -0.805119242261547 +-3.54 -0.853439266993317 -0.847287649509531 -0.713054868660403 -0.185582633511988 -0.796141445263169 -0.837503008644639 +-3.48 -0.890107016225346 -0.882914509463972 -0.736929383803171 -0.189102781975292 -0.826252661263202 -0.871822108156729 +-3.42 -0.929188306937388 -0.920782764893597 -0.761872639318425 -0.192725621968948 -0.857950813837025 -0.908198606803142 +-3.36 -0.970855225127375 -0.961040227359126 -0.787924411855186 -0.196452883593568 -0.891313742545063 -0.946757560038619 +-3.3 -1.015285953967035 -1.003838429701059 -0.815122416358323 -0.200285853436071 -0.9264182808976 -0.987625860082374 +-3.24 -1.06266331616224 -1.049331155498829 -0.843501472283596 -0.204225273547683 -0.963339070428677 -1.030930808436468 +-3.18 -1.113172913359971 -1.097672617852348 -0.87309255173939 -0.208271228276353 -1.002147175233922 -1.076798387137369 +-3.12 -1.167000820011435 -1.149015255143748 -0.90392170473333 -0.21242301865597 -1.042908485412459 -1.125351204525669 +-3.06 -1.224330792335484 -1.203507115088848 -0.936008858671242 -0.216679024288376 -1.085681900727909 -1.176706094819184 +-3. -1.285340958059492 -1.261288803182152 -0.969366491710363 -0.221036552938473 -1.130517289560049 -1.230971355545238 +-2.94 -1.350199959947886 -1.322489978789648 -1.003998182530953 -0.225491678399484 -1.177453222789397 -1.288243613211531 +-2.88 -1.419062535673428 -1.387225390739586 -1.039897042555863 -0.230039067574474 -1.22651448784768 -1.348604315385858 +-2.82 -1.492064528659333 -1.455590455060693 -1.077044040654709 -0.234671798159913 -1.277709394600586 -1.412115856767272 +-2.76 -1.569317339103526 -1.52765639022577 -1.115406234776335 -0.239381168803339 -1.331026892090513 -1.478817357805356 +-2.7 -1.650901841519888 -1.603464940106238 -1.154934929876533 -0.244156504133579 -1.386433523333514 -1.548720126909394 +-2.64 -1.736861814533516 -1.683022730833614 -1.195563786701538 -0.248984957619577 -1.443870254232194 -1.621802851107626 +-2.58 -1.827196950414529 -1.766295326607138 -1.237206911460607 -0.253851315790658 -1.503249222082734 -1.698006575031569 +-2.52 -1.921855535098037 -1.853201067969561 -1.279756961993336 -0.258737807932439 -1.564450458863686 -1.777229543886286 +-2.46 -2.020726914164829 -1.943604796579772 -1.323083311563381 -0.263623925940977 -1.627318654341855 -1.859322002363385 +-2.4 -2.123633885503745 -2.037311590629626 -1.367030316703478 -0.268486259553165 -1.691660033551819 -1.944081057705783 +-2.34 -2.230325184490874 -2.134060654912034 -1.411415740400997 -0.273298352651356 -1.757239432208766 -2.031245730829761 +-2.28 -2.340468251568171 -2.233519528206771 -1.456029386082767 -0.278030586740716 -1.823777661608209 -2.120492333924061 +-2.22 -2.453642494078907 -2.335278787306594 -1.5006320011915 -0.282650097993637 -1.890949261184256 -2.211430325605969 +-2.16 -2.569333273029516 -2.438847440781128 -1.544954511256854 -0.28712073442008 -1.958380741703032 -2.303598804812042 +-2.1 -2.686926859960336 -2.543649215565547 -1.588697646158079 -0.29140305974067 -2.025649424635926 -2.396463811414531 +-2.04 -2.805706618178591 -2.649019944769709 -1.631532019430212 -0.29545441034815 -2.092282983181105 -2.489416604377159 +-1.98 -2.924850665134488 -2.7542062648809 -1.673098718822513 -0.299229011416951 -2.157759787310673 -2.581773086434703 +-1.92 -3.043431267698494 -2.858365824018554 -1.713010461700383 -0.302678157594932 -2.221510148800872 -2.672774537218412 +-1.86 -3.160416208667063 -2.96056918946187 -1.750853362173242 -0.305750462938439 -2.282918552216639 -2.761589803986308 +-1.8 -3.274672340334177 -3.059803621857615 -1.786189347970347 -0.308392183687982 -2.341326944129017 -2.84731908033468 +-1.74 -3.384971509027084 -3.154978855088762 -1.818559254081723 -0.310547616237775 -2.3960391354185 -2.928999378326795 +-1.68 -3.489998993037104 -3.244934984763824 -1.847486607116131 -0.312159571150768 -2.446326350463568 -3.005611768447885 +-1.62 -3.58836454565469 -3.328452524976315 -1.87248209936822 -0.313169922406006 -2.491433932578055 -3.076090424985526 +-1.56 -3.678616075700111 -3.404264642995876 -1.893048734984603 -0.313520229205663 -2.530589187639015 -3.139333472392611 +-1.5 -3.759255931087423 -3.471071525817429 -1.908687612711187 -0.313152425697665 -2.563010317984838 -3.194215581721044 +-1.44 -3.828759678032589 -3.527556772258457 -1.918904290911541 -0.312009571906558 -2.587916367054182 -3.239602216372803 +-1.38 -3.885597191365694 -3.572405641101497 -1.923215661363546 -0.310036657076054 -2.604538062706413 -3.27436537448972 +-1.32 -3.928255792230718 -3.604324921441406 -1.921157239327399 -0.307181444569781 -2.612129414657007 -3.297400622789343 +-1.26 -3.955265090746571 -3.622064127946199 -1.912290759139626 -0.30339534551866 -2.609979890010256 -3.30764516521393 +-1.2 -3.965223115672072 -3.624437663366572 -1.896211947761892 -0.298634306612916 -2.597426961569229 -3.304096641171832 +-1.14 -3.956823243604591 -3.610347535607436 -1.872558333945342 -0.292859695883479 -2.57386879756399 -3.285832304250417 +-1.08 -3.928881379608949 -3.578806169278876 -1.841016938590232 -0.286039169068776 -2.538776839758249 -3.252028194890223 +-1.02 -3.88036279218793 -3.528958814056473 -1.801331683074954 -0.278147498281312 -2.491708000603236 -3.201977891368768 +-0.96 -3.810407977589687 -3.460105026395915 -1.753310347319276 -0.269167344228935 -2.432316200127827 -3.135110404124893 +-0.9 -3.718356855131888 -3.371718688876445 -1.696830908563062 -0.259089953253355 -2.360362960355413 -3.051006770299988 +-0.84 -3.603770787354928 -3.263466034031539 -1.631847095598077 -0.247915760953811 -2.275726779796318 -2.94941490941305 +-0.78 -3.466451553384448 -3.135221157851477 -1.558393001666119 -0.235654885191649 -2.178411023326243 -2.830262317985373 +-0.72 -3.306456923840377 -2.987078542582043 -1.476586612460588 -0.222327492803514 -2.068550083615264 -2.693666210931879 +-0.66 -3.124112159972881 -2.819362158803803 -1.38663212350862 -0.207964026404726 -1.946413599030364 -2.539940760428568 +-0.6 -2.920017029942837 -2.63263078227548 -1.288820943370137 -0.192605280165159 -1.812408549124088 -2.369601138065824 +-0.54 -2.695047975449276 -2.427679240290939 -1.183531305108291 -0.176302316370042 -1.667079091686354 -2.18336413225014 +-0.48 -2.450355178978433 -2.205535393395761 -1.071226437749134 -0.159116217849941 -1.51110405385146 -1.982145188416983 +-0.42 -2.187354404122673 -1.967452758784215 -0.952451281204987 -0.141117674902202 -1.345292042652145 -1.767051802651729 +-0.36 -1.907713611995207 -1.714898788659421 -0.827827761518514 -0.122386409033512 -1.170574196227782 -1.539373287423374 +-0.3 -1.613334491738438 -1.449538927054032 -0.698048677337767 -0.103010439625793 -0.98799465399949 -1.300567018688131 +-0.24 -1.306329178181095 -1.173216678614546 -0.563870282246206 -0.08308520335504 -0.798698880796756 -1.052241363812227 +-0.18 -0.988992560397988 -0.887930029089557 -0.426103679916632 -0.062712539763046 -0.603920034396653 -0.796135576718283 +-0.12 -0.663770706860496 -0.595804656210967 -0.28560517902331 -0.041999559685258 -0.404963616484981 -0.534097027537937 +-0.06 -0.333226041846143 -0.299064457976051 -0.14326578147874 -0.021057416170859 -0.203190692030533 -0.268056206163692 +0.e-16 0.e-16 0.e-16 0.e-16 0.e-16 0.e-16 0.e-16 +0.06 0.333226041846143 0.299064457976051 0.14326578147874 0.021057416170859 0.203190692030533 0.268056206163692 +0.12 0.663770706860496 0.595804656210967 0.28560517902331 0.041999559685258 0.404963616484981 0.534097027537937 +0.18 0.988992560397988 0.887930029089557 0.426103679916632 0.062712539763046 0.603920034396653 0.796135576718283 +0.24 1.306329178181095 1.173216678614546 0.563870282246206 0.08308520335504 0.798698880796756 1.052241363812227 +0.3 1.613334491738438 1.449538927054032 0.698048677337767 0.103010439625793 0.98799465399949 1.300567018688131 +0.36 1.907713611995207 1.714898788659421 0.827827761518514 0.122386409033512 1.170574196227782 1.539373287423374 +0.42 2.187354404122673 1.967452758784215 0.952451281204987 0.141117674902202 1.345292042652145 1.767051802651729 +0.48 2.450355178978433 2.205535393395761 1.071226437749134 0.159116217849941 1.51110405385146 1.982145188416983 +0.54 2.695047975449276 2.427679240290939 1.183531305108291 0.176302316370042 1.667079091686354 2.18336413225014 +0.6 2.920017029942837 2.63263078227548 1.288820943370137 0.192605280165159 1.812408549124088 2.369601138065824 +0.66 3.124112159972881 2.819362158803803 1.38663212350862 0.207964026404726 1.946413599030364 2.539940760428568 +0.72 3.306456923840377 2.987078542582043 1.476586612460588 0.222327492803514 2.068550083615264 2.693666210931879 +0.78 3.466451553384448 3.135221157851477 1.558393001666119 0.235654885191649 2.178411023326243 2.830262317985373 +0.84 3.603770787354928 3.263466034031539 1.631847095598077 0.247915760953811 2.275726779796318 2.94941490941305 +0.9 3.718356855131888 3.371718688876445 1.696830908563062 0.259089953253355 2.360362960355413 3.051006770299988 +0.96 3.810407977589687 3.460105026395915 1.753310347319276 0.269167344228935 2.432316200127827 3.135110404124893 +1.02 3.88036279218793 3.528958814056473 1.801331683074954 0.278147498281312 2.491708000603236 3.201977891368768 +1.08 3.928881379608949 3.578806169278876 1.841016938590232 0.286039169068776 2.538776839758249 3.252028194890223 +1.14 3.956823243604591 3.610347535607436 1.872558333945342 0.292859695883479 2.57386879756399 3.285832304250417 +1.2 3.965223115672072 3.624437663366572 1.896211947761892 0.298634306612916 2.597426961569229 3.304096641171832 +1.26 3.955265090746571 3.622064127946199 1.912290759139626 0.30339534551866 2.609979890010256 3.30764516521393 +1.32 3.928255792230718 3.604324921441406 1.921157239327399 0.307181444569781 2.612129414657007 3.297400622789343 +1.38 3.885597191365694 3.572405641101497 1.923215661363546 0.310036657076054 2.604538062706413 3.27436537448972 +1.44 3.828759678032589 3.527556772258457 1.918904290911541 0.312009571906558 2.587916367054182 3.239602216372803 +1.5 3.759255931087423 3.471071525817429 1.908687612711187 0.313152425697665 2.563010317984838 3.194215581721044 +1.56 3.678616075700111 3.404264642995876 1.893048734984603 0.313520229205663 2.530589187639015 3.139333472392611 +1.62 3.58836454565469 3.328452524976315 1.87248209936822 0.313169922406006 2.491433932578055 3.076090424985526 +1.68 3.489998993037104 3.244934984763824 1.847486607116131 0.312159571150768 2.446326350463568 3.005611768447885 +1.74 3.384971509027084 3.154978855088762 1.818559254081723 0.310547616237775 2.3960391354185 2.928999378326795 +1.8 3.274672340334177 3.059803621857615 1.786189347970347 0.308392183687982 2.341326944129017 2.84731908033468 +1.86 3.160416208667063 2.96056918946187 1.750853362173242 0.305750462938439 2.282918552216639 2.761589803986308 +1.92 3.043431267698494 2.858365824018554 1.713010461700383 0.302678157594932 2.221510148800872 2.672774537218412 +1.98 2.924850665134488 2.7542062648809 1.673098718822513 0.299229011416951 2.157759787310673 2.581773086434703 +2.04 2.805706618178591 2.649019944769709 1.631532019430212 0.29545441034815 2.092282983181105 2.489416604377159 +2.1 2.686926859960336 2.543649215565547 1.588697646158079 0.29140305974067 2.025649424635926 2.396463811414531 +2.16 2.569333273029516 2.438847440781128 1.544954511256854 0.28712073442008 1.958380741703032 2.303598804812042 +2.22 2.453642494078907 2.335278787306594 1.5006320011915 0.282650097993637 1.890949261184256 2.211430325605969 +2.28 2.340468251568171 2.233519528206771 1.456029386082767 0.278030586740716 1.823777661608209 2.120492333924061 +2.34 2.230325184490874 2.134060654912034 1.411415740400997 0.273298352651356 1.757239432208766 2.031245730829761 +2.4 2.123633885503745 2.037311590629626 1.367030316703478 0.268486259553165 1.691660033551819 1.944081057705783 +2.46 2.020726914164829 1.943604796579772 1.323083311563381 0.263623925940977 1.627318654341855 1.859322002363385 +2.52 1.921855535098037 1.853201067969561 1.279756961993336 0.258737807932439 1.564450458863686 1.777229543886286 +2.58 1.827196950414529 1.766295326607138 1.237206911460607 0.253851315790658 1.503249222082734 1.698006575031569 +2.64 1.736861814533516 1.683022730833614 1.195563786701538 0.248984957619577 1.443870254232194 1.621802851107626 +2.7 1.650901841519888 1.603464940106238 1.154934929876533 0.244156504133579 1.386433523333514 1.548720126909394 +2.76 1.569317339103526 1.52765639022577 1.115406234776335 0.239381168803339 1.331026892090513 1.478817357805356 +2.82 1.492064528659333 1.455590455060693 1.077044040654709 0.234671798159913 1.277709394600586 1.412115856767272 +2.88 1.419062535673428 1.387225390739586 1.039897042555863 0.230039067574474 1.22651448784768 1.348604315385858 +2.94 1.350199959947886 1.322489978789648 1.003998182530953 0.225491678399484 1.177453222789397 1.288243613211531 +3. 1.285340958059492 1.261288803182152 0.969366491710363 0.221036552938473 1.130517289560049 1.230971355545238 +3.06 1.224330792335484 1.203507115088848 0.936008858671242 0.216679024288376 1.085681900727909 1.176706094819184 +3.12 1.167000820011435 1.149015255143748 0.90392170473333 0.21242301865597 1.042908485412459 1.125351204525669 +3.18 1.113172913359971 1.097672617852348 0.87309255173939 0.208271228276353 1.002147175233922 1.076798387137369 +3.24 1.06266331616224 1.049331155498829 0.843501472283596 0.204225273547683 0.963339070428677 1.030930808436468 +3.3 1.015285953967035 1.003838429701059 0.815122416358323 0.200285853436071 0.9264182808976 0.987625860082374 +3.36 0.970855225127375 0.961040227359126 0.787924411855186 0.196452883593568 0.891313742545063 0.946757560038619 +3.42 0.929188306937388 0.920782764893597 0.761872639318425 0.192725621968948 0.857950813837025 0.908198606803142 +3.48 0.890107016225346 0.882914509463972 0.736929383803171 0.189102781975292 0.826252661263202 0.871822108156729 +3.54 0.853439266993317 0.847287649509531 0.713054868660403 0.185582633511988 0.796141445263169 0.837503008644639 +3.6 0.819020169191834 0.813759248934541 0.690207977586379 0.18216309232437 0.767539320287618 0.805119242261547 +3.66 0.786692812817072 0.782192120075493 0.66834687237715 0.178841798325576 0.740369264080279 0.774552638017904 +3.72 0.756308780454608 0.752455450361287 0.647429514562855 0.175616183606662 0.714555752070589 0.745689606371449 +3.78 0.727728429416803 0.724425216513491 0.627414099510064 0.172483530927243 0.690025293051141 0.718421634067966 +3.84 0.700820981960204 0.697984418419698 0.60825941172144 0.169441023514861 0.666706842164933 0.69264561390118 +3.9 0.675464458932848 0.673023162620123 0.589925109977838 0.166485787011647 0.644532106730759 0.668264034413053 +3.96 0.65154548877234 0.649438622830158 0.572371950703606 0.163614924396416 0.62343575966923 0.645185052740922 +4.02 0.628959020210432 0.627134902213669 0.555561957532726 0.160825544683309 0.603355574329254 0.623322471789879 +4.08 0.607607963468264 0.606022819337196 0.539458544549109 0.15811478615856 0.584232493418817 0.602595640765301 +4.14 0.587402781252272 0.586019636967288 0.524026600101693 0.155479834868373 0.566010643569943 0.582929295923149 +4.2 0.568261047563319 0.567048750195972 0.509232537482513 0.152917939016373 0.548637305862097 0.564253356251102 +4.26 0.550106989268224 0.54903934784861 0.495044318127313 0.150426419871211 0.532062851429066 0.546502686733427 +4.32 0.532871023280858 0.53192605871619 0.481431452372396 0.148002679725851 0.516240650111513 0.529616839848929 +4.38 0.516489294185473 0.515648592565513 0.46836498219488 0.145644207391591 0.501126959013664 0.513539784695956 +4.44 0.500903234242991 0.500151382070575 0.455817449785611 0.143348581653291 0.48668079679385 0.498219629655783 +4.5 0.486059127207212 0.485383233937644 0.443762855265095 0.141113473058658 0.472863808576468 0.483608346782469 +4.56 0.471907704026378 0.47129699128579 0.432176606356655 0.138936644364383 0.459640125521418 0.469661500181878 +4.62 0.458403758542152 0.457849211913842 0.421035462381539 0.136815949916017 0.446976222330087 0.456337983265444 +4.68 0.445505789496515 0.444999864144437 0.410317474538181 0.134749334196794 0.434840775301475 0.443599766964302 +4.74 0.43317566875222 0.432712041626281 0.400001924072191 0.13273482974331 0.423204522976121 0.431411660734167 +4.8 0.421378335624961 0.420951697718346 0.390069259632906 0.130770554592987 0.412040130912185 0.41974108746451 +4.86 0.410081516695406 0.40968739953549 0.380501034843946 0.128854709399271 0.401322061722229 0.408557872878621 +4.92 0.399255470080714 0.398890101316289 0.37127984688606 0.126985574325505 0.391026451152862 0.397834049592349 +4.98 0.388872752875012 0.388532936462194 0.362389276696976 0.125161505806847 0.381130990705433 0.387543675674362 +5.04 0.378908010295167 0.378591027375272 0.353813831231502 0.123380933251325 0.371614817066699 0.377662667306034 +5.1 0.369337784973051 0.369041312073897 0.345538888091861 0.121642355735701 0.362458408436666 0.368168644961581 +5.16 0.360140344801548 0.359862386477687 0.337550642729865 0.119944338738998 0.353643487699854 0.359040792407264 +5.22 0.351295527754455 0.351034361212299 0.329836058335435 0.118285510945827 0.345152932279572 0.350259727741917 +5.28 0.342784602147875 0.342538731780674 0.322382818457214 0.116664561143113 0.336970690436887 0.34180738566051 +5.34 0.334590140882672 0.334358260970822 0.315179282347658 0.115080235226671 0.329081703721572 0.333666910110072 +5.4 0.326695908295686 0.32647687241365 0.308214442984485 0.113531333328536 0.321471835247027 0.325822556516324 +5.46 0.319086758345141 0.318879554261481 0.301477887690525 0.112016707071577 0.314127803441033 0.318259602784132 +5.52 0.311748542957857 0.311552272023611 0.29495976125277 0.110535256953557 0.307037120916026 0.310964268310789 +5.58 0.304668029468551 0.304481889665772 0.288650731427132 0.10908592986321 0.300188038103393 0.303923640294388 +5.64 0.297832826181772 0.297656098152312 0.282541956707611 0.107667716723571 0.293569491303868 0.297125606667076 +5.7 0.291231315183612 0.291063350682117 0.27662505623096 0.106279650261658 0.287171054819377 0.290558795033396 +5.76 0.284852591618508 0.284692803936369 0.270892081693457 0.104920802900283 0.280982896845394 0.284212517041818 +5.82 0.278686408732781 0.278534264724715 0.26533549114963 0.103590284765086 0.274995738823736 0.278076717669295 +5.88 0.272723128062216 0.272578141476905 0.259948124572655 0.102287241804509 0.269200817973769 0.272141928944631 +5.94 0.266953674208605 0.266815400081879 0.254723181057423 0.101010854014917 0.263589852737481 0.266399227678862 +6. 0.261369493716395 0.261237523631927 0.249654197553638 0.09976033376621 0.258155010896897 0.260840196815813 diff --git a/examples/benchmark_fftx/run_fieldplots_Ex.py b/examples/benchmark_fftx/run_fieldplots_Ex.py new file mode 100644 index 000000000..5430668ce --- /dev/null +++ b/examples/benchmark_fftx/run_fieldplots_Ex.py @@ -0,0 +1,184 @@ +#!/usr/bin/env python3 +# +# Copyright 2022 ImpactX contributors +# Authors: Axel Huebl, Christopher E. Mayes +# License: BSD-3-Clause-LBNL +# +# Benchmark as in Figure 1 of +# C. E. Mayes, R. D. Ryne, and D. C. Sagan, "3D Space Charge in BMAD," in proc. IPAC2018, +# DOI:10.18429/JACoW-IPAC2018-THPAK085 +# +# -*- coding: utf-8 -*- + +import matplotlib.pyplot as plt +import numpy as np +import pandas as pd + +import amrex.space3d as amr +from impactx import ImpactX, RefPart, distribution, elements + +# theory data from eq. (1) in Mayes, sampled to text files in +theory = pd.read_csv("Ex_Mayes.dat", header=0, sep=r"\s+") +x_theory = theory["x/sigmax"] + + +def run_and_plot(case, r, ax): + """Run ImpactX for a new r and plot + + Parameters + ---------- + case : string + case name + r : Float + aspect ratio = sigma_z / sigma_perp: range 0.1 to 10 + ax : matplotlib.axes + a figure axis to plot into + """ + sim = ImpactX() + + # set numerical parameters and IO control + sim.n_cell = [128, 128, 128] + sim.particle_shape = 2 # B-spline order + sim.space_charge = True + sim.dynamic_size = True + sim.poisson_solver = "fft" + sim.prob_relative = [1.01, 1.01] + + # beam diagnostics + sim.diagnostics = False + sim.slice_step_diagnostics = False + + # domain decomposition & space charge mesh + sim.init_grids() + + # load a cold 10 MeV electron beam + mass_MeV = 0.510998950 # electron mass in MeV/c^2 + energy_MeV = 1.000001 * mass_MeV # reference energy (total) + bunch_charge_C = 1.0e-9 # charge in C + npart = int(10000000) # number of macro particles + + # reference particle (Mayes Fig. 1 is for + charge) + ref = sim.particle_container().ref_particle() + kinetic_MeV = energy_MeV - mass_MeV + ref.set_charge_qe(1.0).set_mass_MeV(mass_MeV).set_kin_energy_MeV(kinetic_MeV) + + # particle bunch + sigma_r = 1.0e-3 # fixed at 1 mm + sigma_z = r * sigma_r + gamma = energy_MeV / mass_MeV + beta = (1.0 - (1.0 / gamma) ** 2) ** 0.5 + c0 = 2.99792458e8 # speed of light in m/s + sigma_t = sigma_z / (beta * gamma) # recall t is implicitly scaled by c0 + print(f"r={r} sigma_t={sigma_t}m") + + distr = distribution.Gaussian( + lambdaX=sigma_r, + lambdaY=sigma_r, + lambdaT=sigma_t, + lambdaPx=0.0, + lambdaPy=0.0, + lambdaPt=0.0, + ) + sim.add_particles(bunch_charge_C, distr, npart) + + # add beam diagnostics + monitor = elements.BeamMonitor("monitor", backend="h5") + + # design the accelerator lattice + sim.lattice.extend([monitor]) + + # run simulation + sim.evolve() + + # plotting + + # simulation data + F_x = sim.space_charge_field(lev=0, comp="x") # [V/m] in the lab frame + + gm = sim.Geom(lev=0) + dr = gm.data().CellSize() + dV = np.prod(dr) + + half_x, half_y, half_z = [n // 2 for n in sim.n_cell] # order: x,y,z + + # plot theory + p = ax.plot(x_theory, theory[case], label=case) # E_x(sigma_r) [MV/m] + line_color = p[0].get_color() + + # plot data slices + ng = F_x.n_grow_vect + q_e = -1.602176634e-19 + for mfi in F_x: + bx = mfi.validbox() + rbx = amr.RealBox(bx, dr, gm.ProbLo()) + + arr_np = F_x.array(mfi).to_numpy(copy=True) # indices: x, y, z, comp + + # crop off guard cells + arr_np = arr_np[ng[0] : -ng[0], ng[1] : -ng[1], ng[2] : -ng[2]] + + # shift box to zero-based local mfi index space + half_y_local = half_y - bx.lo_vect[1] + half_z_local = half_z - bx.lo_vect[2] + + # check if the current tile contains the half-y plane + if half_y_local < 0 or half_y >= bx.hi_vect[1]: + continue + # check if the current tile contains the half-z plane + if half_z_local < 0 or half_z >= bx.hi_vect[2]: + continue + + comp = 0 + lineout = arr_np[..., half_y_local, half_z_local, comp] # w/o guard, N + E_x = lineout / gamma / 1.0e6 # E_x(x[m]) [MV/m] + ax.plot( + np.linspace(rbx.lo(0) / sigma_r, rbx.hi(0) / sigma_r, E_x.shape[0]), + E_x, + "o", + markersize=2, + color=line_color, + ) + + # clean shutdown + del sim + + +f = plt.figure() +ax = f.gca() + +run_and_plot("r=0.1", 0.1, ax) +run_and_plot("r=0.2", 0.2, ax) +run_and_plot("r=0.5", 0.5, ax) +run_and_plot("r=1", 1, ax) +run_and_plot("r=10", 10, ax) + + +# Charge density (Gaussian, normalized) +def gauss(x): + return np.exp(-(x**2) / 2) + + +ax2 = ax.twinx() +ax2.fill_between(x_theory, 0, gauss(x_theory), color="gray", alpha=0.2) + +xmin = -6.0 +xmax = 6.0 +ymin = -6.0 +ymax = 6.0 +ax.set_xlim([xmin, xmax]) +ax.set_ylim([ymin, ymax]) +ax2.set_ylim([-1.2, 1.2]) +ax2.set_yticks([0, 0.5, 1.0]) + +# ax2.spines['right'].set_color('gray') +ax2.yaxis.label.set_color("gray") +ax2.tick_params(colors="gray", which="both") + +ax.set_xlabel(r"$x$ [$\sigma_x$]") +ax.set_ylabel(r"$E_x$ [MV/m]") +ax2.set_ylabel(r"charge density [arb. u.]") +ax.legend(loc="upper left") +plt.show() + +# clean shutdown +amr.finalize() From 4503aec7fabcd23beb218c26898d3a0224a13169 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:00:00 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/benchmark_fftx/run_fieldplots_Ex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/benchmark_fftx/run_fieldplots_Ex.py b/examples/benchmark_fftx/run_fieldplots_Ex.py index 5430668ce..01a35c5b4 100644 --- a/examples/benchmark_fftx/run_fieldplots_Ex.py +++ b/examples/benchmark_fftx/run_fieldplots_Ex.py @@ -15,7 +15,7 @@ import pandas as pd import amrex.space3d as amr -from impactx import ImpactX, RefPart, distribution, elements +from impactx import ImpactX, distribution, elements # theory data from eq. (1) in Mayes, sampled to text files in theory = pd.read_csv("Ex_Mayes.dat", header=0, sep=r"\s+") From ce271d1c4eeaeb1eee1158fae444ac911cc969b3 Mon Sep 17 00:00:00 2001 From: Chad Mitchell <46825199+cemitch99@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:23:48 -0800 Subject: [PATCH 3/3] Update run_fieldplots_Ex.py Remove assignment of unused variables. --- examples/benchmark_fftx/run_fieldplots_Ex.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/benchmark_fftx/run_fieldplots_Ex.py b/examples/benchmark_fftx/run_fieldplots_Ex.py index 01a35c5b4..980be2fa8 100644 --- a/examples/benchmark_fftx/run_fieldplots_Ex.py +++ b/examples/benchmark_fftx/run_fieldplots_Ex.py @@ -67,7 +67,6 @@ def run_and_plot(case, r, ax): sigma_z = r * sigma_r gamma = energy_MeV / mass_MeV beta = (1.0 - (1.0 / gamma) ** 2) ** 0.5 - c0 = 2.99792458e8 # speed of light in m/s sigma_t = sigma_z / (beta * gamma) # recall t is implicitly scaled by c0 print(f"r={r} sigma_t={sigma_t}m") @@ -97,7 +96,6 @@ def run_and_plot(case, r, ax): gm = sim.Geom(lev=0) dr = gm.data().CellSize() - dV = np.prod(dr) half_x, half_y, half_z = [n // 2 for n in sim.n_cell] # order: x,y,z @@ -107,7 +105,6 @@ def run_and_plot(case, r, ax): # plot data slices ng = F_x.n_grow_vect - q_e = -1.602176634e-19 for mfi in F_x: bx = mfi.validbox() rbx = amr.RealBox(bx, dr, gm.ProbLo())