Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Maxwellian away from walls in initial condition for wall-bc sims #218

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions moment_kinetics/src/initial_conditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,15 @@ function init_ion_pdf_over_density!(pdf, spec, composition, vpa, vperp, z,
right_weight*upper_z_pdf_buffer)
end

# Add a non-flowing Maxwellian (that vanishes at the sheath entrance boundaries) to try to
# avoid the 'hole' in the distribution function that can drive instabilities.
@loop_z_vperp iz ivperp begin
@. pdf[:,ivperp,iz] += spec.z_IC.density_amplitude *
(1.0 - (2.0 * z.grid[iz] / z.L)^2) *
exp(-(vpa.grid^2 + vperp.grid[ivperp]^2)
/ vth[iz]^2) / vth[iz]
end

# Get the unnormalised pdf and the moments of the constructed full-f
# distribution function (which will be modified from the input moments).
convert_full_f_ion_to_normalised!(pdf, density, upar, ppar, vth, vperp,
Expand Down
56 changes: 28 additions & 28 deletions moment_kinetics/test/fokker_planck_time_evolution_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,47 +39,47 @@ const expected =
[-3.0, -2.5, -2.0, -1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0],
[0.155051025721682, 0.644948974278318, 1.000000000000000, 1.500000000000000, 2.000000000000000, 2.500000000000000, 3.000000000000000],
# Expected phi:
[-1.267505494648937, -1.275683298550937],
[-1.268504994982021, -1.276675261324553],
# Expected n_ion:
[0.2815330322340072, 0.2792400986636072],
[0.28125178045355353, 0.278963240220169],
# Expected upar_ion:
[0.0, 0.0],
# Expected ppar_ion:
[0.17982280248048935, 0.14891126175332367],
[0.17964315932116812, 0.148762861611732],
# Expected pperp_ion
[0.14340146667506784, 0.1581377822859991],
[0.14325820846660123, 0.15798027481288696],
# Expected qpar_ion
[0.0, 0.0],
# Expected v_t_ion
[1.0511726083010418, 1.0538509291794658],
[1.0511726083010418, 1.0538484394097123],
# Expected dSdt
[0.0, 1.1853081348031516e-5],
[0.0, 1.1831920390587679e-5],
# Expected f_ion:
[0.0 0.0 0.0 0.0 0.0 0.0 0.0;
0.0006199600161806666 0.00047805300997075977 0.0002665817112117718 7.637693901737056e-5 1.3272321881722645e-5 1.3988924344690309e-6 0.0;
0.005882016862626724 0.0045356406743786385 0.002529256854781707 0.0007246442213864763 0.00012592428394890537 1.3272321881722645e-5 0.0;
0.03384866997225574 0.026100809957763767 0.01455486826237011 0.004170039574837177 0.000724644221263874 7.637693900444835e-5 0.0;
0.11813810317200342 0.09109664226661075 0.05079917556123135 0.01455420747483572 0.0025291420266981487 0.0002665696084208068 0.0;
0.22957946520936198 0.17702940755267918 0.0987187642706944 0.0282833995036643 0.004914917865936108 0.0005180285318549189 0.0;
0.0006193406755051616 0.0004775754345362236 0.0002663153958159559 7.630063837899157e-5 1.3259062818903743e-5 1.3974949395295016e-6 0.0;
0.005876140721904817 0.0045311095648138235 0.00252673012465705 0.000723920301085391 0.00012579848546344195 1.3259062818903743e-5 0.0;
0.0338148551171386 0.026074735222541223 0.01454032793443568 0.004165873701136042 0.000723920300962911 7.630063836608227e-5 0.0;
0.11802008308891455 0.09100563662998079 0.05074842713409726 0.014539667807028695 0.0025266154112868616 0.0002663033051156912 0.0;
0.22935011509426767 0.1768525549976815 0.09862014412656786 0.028255144359305 0.00491000785807803 0.0005175110208340848 0.0;
0.0 0.0 0.0 0.0 0.0 0.0 0.0;
0.22957946520936204 0.1770294075526792 0.0987187642706944 0.0282833995036643 0.004914917865936108 0.0005180285318549189 0.0;
0.11813810317200349 0.0910966422666108 0.050799175561231376 0.01455420747483573 0.0025291420266981487 0.0002665696084208068 0.0;
0.03384866997225574 0.026100809957763767 0.01455486826237011 0.004170039574837177 0.000724644221263874 7.637693900444835e-5 0.0;
0.005882016862626724 0.0045356406743786385 0.002529256854781707 0.0007246442213864763 0.00012592428394890537 1.3272321881722645e-5 0.0;
0.0006199600161806666 0.00047805300997075977 0.0002665817112117718 7.637693901737056e-5 1.3272321881722645e-5 1.3988924344690309e-6 0.0;
0.22935011509426778 0.17685255499768154 0.09862014412656786 0.028255144359305 0.00491000785807803 0.0005175110208340848 0.0;
0.1180200830889146 0.09100563662998083 0.05074842713409728 0.014539667807028703 0.0025266154112868616 0.0002663033051156912 0.0;
0.0338148551171386 0.026074735222541223 0.01454032793443568 0.004165873701136042 0.000723920300962911 7.630063836608227e-5 0.0;
0.005876140721904817 0.0045311095648138235 0.00252673012465705 0.000723920301085391 0.00012579848546344195 1.3259062818903743e-5 0.0;
0.0006193406755051616 0.0004775754345362236 0.0002663153958159559 7.630063837899157e-5 1.3259062818903743e-5 1.3974949395295016e-6 0.0;
0.0 0.0 0.0 0.0 0.0 0.0 0.0;;;
0.0 0.0 0.0 0.0 0.0 0.0 0.0;
0.0001712743622973216 7.105465094508053e-5 -7.829380680167827e-5 -0.00015364081956318698 -9.097098213067502e-5 -3.311284120491419e-5 0.0;
0.005883280697248667 0.004667594200766182 0.002855965521103658 0.0008138347136178689 2.44260649525292e-5 -9.753249634264602e-5 0.0;
0.02792209301450194 0.022385716644538384 0.01413535091105969 0.004677801530322722 0.0007105315221401102 -0.00022400635166536323 0.0;
0.08117458037332098 0.06563459159004267 0.04247673844050208 0.015087784332275832 0.0029056314178876035 -0.00023019804543218203 0.0;
0.15133793170654106 0.12313903060106579 0.08111673445361306 0.029975277983613262 0.00626735398468981 7.553501812465833e-6 0.0;
0.18493902160817713 0.15073513412904313 0.09976414473955808 0.037251581926306565 0.007941836186495122 0.00016196175024033304 0.0;
0.15133793170654092 0.12313903060106571 0.08111673445361306 0.02997527798361324 0.006267353984689816 7.553501812469816e-6 0.0;
0.081174580373321 0.06563459159004267 0.042476738440502065 0.015087784332275821 0.002905631417887614 -0.0002301980454321778 0.0;
0.027922093014501933 0.022385716644538384 0.014135350911059698 0.004677801530322729 0.0007105315221401184 -0.00022400635166536134 0.0;
0.005883280697248667 0.004667594200766184 0.002855965521103663 0.0008138347136178759 2.4426064952530956e-5 -9.753249634264635e-5 0.0;
0.0001712743622973275 7.105465094508572e-5 -7.829380680167411e-5 -0.00015364081956318568 -9.097098213067551e-5 -3.311284120491447e-5 0.0;
0.00017108987342944037 7.097261590252227e-5 -7.822316408658004e-5 -0.000153489754637506 -9.087984332447761e-5 -3.307937957312587e-5 0.0;
0.005877384425022921 0.004662912823128315 0.002853094592035005 0.0008130106752860298 2.4399432485772724e-5 -9.74348090421241e-5 0.0;
0.02789429969714529 0.022363413859309983 0.014121230173998248 0.004673094872084004 0.0007098078939540657 -0.0002237857510708618 0.0;
0.08109427896718696 0.06556961121847364 0.04243458963422585 0.01507272286376149 0.0029027058292680945 -0.0002299783231637593 0.0;
0.1511887162169901 0.12301753182687214 0.08103653941734254 0.029945484317773212 0.0062610744742386155 7.528837370841561e-6 0.0;
0.184756848099325 0.1505865499710698 0.09966561578213134 0.037214599991686845 0.007933889035324836 0.00016178010211991204 0.0;
0.1511887162169905 0.12301753182687247 0.08103653941734275 0.029945484317773295 0.006261074474238628 7.528837370846196e-6 0.0;
0.08109427896718732 0.06556961121847393 0.042434589634226055 0.015072722863761552 0.0029027058292681127 -0.0002299783231637549 0.0;
0.027894299697145436 0.022363413859310108 0.014121230173998337 0.00467309487208404 0.0007098078939540783 -0.00022378575107086105 0.0;
0.005877384425022965 0.00466291282312835 0.0028530945920350282 0.0008130106752860425 2.4399432485774198e-5 -9.743480904212476e-5 0.0;
0.00017108987342944414 7.097261590252536e-5 -7.822316408657793e-5 -0.0001534897546375058 -9.087984332447822e-5 -3.3079379573126077e-5 0.0;
0.0 0.0 0.0 0.0 0.0 0.0 0.0])
###########################################################################################
# to modify the test, with a new expected f, print the new f using the following commands
Expand Down Expand Up @@ -135,7 +135,7 @@ test_input_gauss_legendre = Dict("run_name" => "gausslegendre_pseudospectral",
"electron_physics" => "boltzmann_electron_response",
"fokker_planck_collisions" => Dict{String,Any}("use_fokker_planck" => true, "nuii" => 1.0, "frequency_option" => "manual"),
"z_IC_upar_amplitude1" => 0.0,
"z_IC_density_amplitude1" => 0.001,
"z_IC_density_amplitude1" => 0.0,
"z_IC_upar_amplitude2" => 0.0,
"z_IC_temperature_phase1" => 0.0,
"z_IC_temperature_amplitude1" => 0.0,
Expand Down
2 changes: 1 addition & 1 deletion moment_kinetics/test/harrisonthompson.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test_input_finite_difference = Dict("n_ion_species" => 1,
"initial_density1" => 1.0,
"initial_temperature1" => 1.0,
"z_IC_option1" => "gaussian",
"z_IC_density_amplitude1" => 0.001,
"z_IC_density_amplitude1" => 0.0,
"z_IC_density_phase1" => 0.0,
"z_IC_upar_amplitude1" => 0.0,
"z_IC_upar_phase1" => 0.0,
Expand Down
2 changes: 1 addition & 1 deletion moment_kinetics/test/recycling_fraction_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_input = Dict("n_ion_species" => 1,
"initial_density1" => 1.0,
"initial_temperature1" => 1.0,
"z_IC_option1" => "gaussian",
"z_IC_density_amplitude1" => 0.001,
"z_IC_density_amplitude1" => 0.0,
"z_IC_density_phase1" => 0.0,
"z_IC_upar_amplitude1" => 1.0,
"z_IC_upar_phase1" => 0.0,
Expand Down
2 changes: 1 addition & 1 deletion moment_kinetics/test/wall_bc_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test_input_finite_difference = Dict("n_ion_species" => 1,
"initial_density1" => 1.0,
"initial_temperature1" => 1.0,
"z_IC_option1" => "gaussian",
"z_IC_density_amplitude1" => 0.001,
"z_IC_density_amplitude1" => 0.0,
"z_IC_density_phase1" => 0.0,
"z_IC_upar_amplitude1" => 0.0,
"z_IC_upar_phase1" => 0.0,
Expand Down
Loading