Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed index bugs and re-ordered accel calcs for better consistency wi…
Browse files Browse the repository at this point in the history
…th old code. Runs match, except for small differences with test particles with oblateness enabled
  • Loading branch information
daminton committed Jul 29, 2021
1 parent 79ea6ac commit e32e3d6
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 249 deletions.
48 changes: 24 additions & 24 deletions examples/symba_swifter_comparison/8pl_16tp_encounters/pl.in
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
8
1 4.9125474498983623693e-11 0.0014751238438755500459
1 4.9125474498983623693e-11 0.0014751239400086721089
1.6306381826061645943e-05
-0.065841771551149230746 0.30388831943526661838 0.030872485461978960153
-0.033141166233939436947 -0.0049297226604189817514 0.0026371811668407158825
2 7.243452483873646905e-10 0.006759080797928606587
-0.09861361766419070307 0.29750596935836171042 0.03335708456145129036
-0.032353632540864457612 -0.0078122718370876240157 0.0023293874953380202045
2 7.243452483873646905e-10 0.0067590794275223005208
4.0453784346544178454e-05
-0.65269716062695148917 -0.3065765656441301057 0.033456491497379246824
0.008459831335658639026 -0.0184014319837384685 -0.0007407193515014080928
3 8.9970113821660187435e-10 0.010044868190633438806
-0.6439817957564198947 -0.3248550380869373866 0.032702713983447248558
0.008969709495375973937 -0.018153139924556138673 -0.0007667345025597138231
3 8.9970113821660187435e-10 0.010044873080337524463
4.25875607065040958e-05
0.58046286084934750615 -0.8332000042504307258 3.7646553415201541957e-05
0.013836557832279990782 0.009770187318278569788 -5.1179589633921335467e-07
4 9.549535102761465607e-11 0.0072467082986392815006
0.59421674333603324847 -0.82331253628773626296 3.7129329104855261984e-05
0.013670550280388280365 0.010004295439859960809 -5.226292361234363611e-07
4 9.549535102761465607e-11 0.0072467054748629370034
2.265740805092889601e-05
-1.5891417403740180081 0.4938480736359250889 0.049330990309104823244
-0.0036308073545784510204 -0.012168467501132099878 -0.00016594932370266260858
5 2.825345908631354893e-07 0.3552707649709459117
-1.592721551706784977 0.48166390206865000723 0.049163460846716633412
-0.0035287723306552309585 -0.01219974682608557931 -0.00016910795626524249315
5 2.825345908631354893e-07 0.35527074967975702942
0.00046732617030490929307
4.1148395833578952363 -2.8938323061728068453 -0.080043092204059404504
0.0042549773877191511204 0.006534697671907701254 -0.00012233719535540690457
6 8.459715183006415395e-08 0.43765596788571493287
4.119089774477131094 -2.8872942462256898644 -0.080165336328135106125
0.004245402942744468111 0.0065414198811065849687 -0.00012215100047356211078
6 8.459715183006415395e-08 0.4376562090257202473
0.00038925687730393611812
6.3589256477393849565 -7.653288021415167286 -0.12000977499446359442
0.003985370599203661747 0.0035590677039893160206 -0.00022043610541731448703
7 1.2920249163736673626e-08 0.46957663585116591335
6.3629100567525149756 -7.649727796147929304 -0.12023019299387090186
0.0039834472120812329868 0.0035613826786502411278 -0.00022039988214595340028
7 1.2920249163736673626e-08 0.4695793205674148502
0.00016953449859497231466
14.816779495279050138 13.049265812461410263 -0.14351615042000470668
-0.0026245225263081049631 0.002774730265364384104 4.416262654344997005e-05
8 1.5243589003230834323e-08 0.7813355837717117843
14.814154683311180349 13.052040295401360126 -0.14347198499748289868
-0.002625101393275708784 0.0027742356008832688187 4.416821810149910185e-05
8 1.5243589003230834323e-08 0.7813388398513013378
0.000164587904124493665
29.564459991843019537 -4.5824598513731222837 -0.5870359532621901577
0.0004648344125208179762 0.0031282868879460171488 -7.5042704502708602616e-05
29.564924658285640646 -4.579331535234244299 -0.5871109926822926095
0.00046449847307956888343 0.003128345390031967918 -7.5036135696161668576e-05
48 changes: 24 additions & 24 deletions examples/symba_swifter_comparison/8pl_16tp_encounters/pl.swifter.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
0 0.00029591220819207775568
0.0 0.0 0.0
0.0 0.0 0.0
1 4.9125474498983623693e-11 0.0014751238438755500459
1 4.9125474498983623693e-11 0.0014751239400086721089
1.6306381826061645943e-05
-0.065841771551149230746 0.30388831943526661838 0.030872485461978960153
-0.033141166233939436947 -0.0049297226604189817514 0.0026371811668407158825
2 7.243452483873646905e-10 0.006759080797928606587
-0.09861361766419070307 0.29750596935836171042 0.03335708456145129036
-0.032353632540864457612 -0.0078122718370876240157 0.0023293874953380202045
2 7.243452483873646905e-10 0.0067590794275223005208
4.0453784346544178454e-05
-0.65269716062695148917 -0.3065765656441301057 0.033456491497379246824
0.008459831335658639026 -0.0184014319837384685 -0.0007407193515014080928
3 8.9970113821660187435e-10 0.010044868190633438806
-0.6439817957564198947 -0.3248550380869373866 0.032702713983447248558
0.008969709495375973937 -0.018153139924556138673 -0.0007667345025597138231
3 8.9970113821660187435e-10 0.010044873080337524463
4.25875607065040958e-05
0.58046286084934750615 -0.8332000042504307258 3.7646553415201541957e-05
0.013836557832279990782 0.009770187318278569788 -5.1179589633921335467e-07
4 9.549535102761465607e-11 0.0072467082986392815006
0.59421674333603324847 -0.82331253628773626296 3.7129329104855261984e-05
0.013670550280388280365 0.010004295439859960809 -5.226292361234363611e-07
4 9.549535102761465607e-11 0.0072467054748629370034
2.265740805092889601e-05
-1.5891417403740180081 0.4938480736359250889 0.049330990309104823244
-0.0036308073545784510204 -0.012168467501132099878 -0.00016594932370266260858
5 2.825345908631354893e-07 0.3552707649709459117
-1.592721551706784977 0.48166390206865000723 0.049163460846716633412
-0.0035287723306552309585 -0.01219974682608557931 -0.00016910795626524249315
5 2.825345908631354893e-07 0.35527074967975702942
0.00046732617030490929307
4.1148395833578952363 -2.8938323061728068453 -0.080043092204059404504
0.0042549773877191511204 0.006534697671907701254 -0.00012233719535540690457
6 8.459715183006415395e-08 0.43765596788571493287
4.119089774477131094 -2.8872942462256898644 -0.080165336328135106125
0.004245402942744468111 0.0065414198811065849687 -0.00012215100047356211078
6 8.459715183006415395e-08 0.4376562090257202473
0.00038925687730393611812
6.3589256477393849565 -7.653288021415167286 -0.12000977499446359442
0.003985370599203661747 0.0035590677039893160206 -0.00022043610541731448703
7 1.2920249163736673626e-08 0.46957663585116591335
6.3629100567525149756 -7.649727796147929304 -0.12023019299387090186
0.0039834472120812329868 0.0035613826786502411278 -0.00022039988214595340028
7 1.2920249163736673626e-08 0.4695793205674148502
0.00016953449859497231466
14.816779495279050138 13.049265812461410263 -0.14351615042000470668
-0.0026245225263081049631 0.002774730265364384104 4.416262654344997005e-05
8 1.5243589003230834323e-08 0.7813355837717117843
14.814154683311180349 13.052040295401360126 -0.14347198499748289868
-0.002625101393275708784 0.0027742356008832688187 4.416821810149910185e-05
8 1.5243589003230834323e-08 0.7813388398513013378
0.000164587904124493665
29.564459991843019537 -4.5824598513731222837 -0.5870359532621901577
0.0004648344125208179762 0.0031282868879460171488 -7.5042704502708602616e-05
29.564924658285640646 -4.579331535234244299 -0.5871109926822926095
0.00046449847307956888343 0.003128345390031967918 -7.5036135696161668576e-05
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
8
1 4.9125474498983623693e-11 0.0014751238438755500459
1 4.9125474498983623693e-11 0.0014751239400086721089
1.6306381826061645943e-05
-0.065841771551149230746 0.30388831943526661838 0.030872485461978960153
-0.033141166233939436947 -0.0049297226604189817514 0.0026371811668407158825
2 7.243452483873646905e-10 0.006759080797928606587
-0.09861361766419070307 0.29750596935836171042 0.03335708456145129036
-0.032353632540864457612 -0.0078122718370876240157 0.0023293874953380202045
2 7.243452483873646905e-10 0.0067590794275223005208
4.0453784346544178454e-05
-0.65269716062695148917 -0.3065765656441301057 0.033456491497379246824
0.008459831335658639026 -0.0184014319837384685 -0.0007407193515014080928
3 8.9970113821660187435e-10 0.010044868190633438806
-0.6439817957564198947 -0.3248550380869373866 0.032702713983447248558
0.008969709495375973937 -0.018153139924556138673 -0.0007667345025597138231
3 8.9970113821660187435e-10 0.010044873080337524463
4.25875607065040958e-05
0.58046286084934750615 -0.8332000042504307258 3.7646553415201541957e-05
0.013836557832279990782 0.009770187318278569788 -5.1179589633921335467e-07
4 9.549535102761465607e-11 0.0072467082986392815006
0.59421674333603324847 -0.82331253628773626296 3.7129329104855261984e-05
0.013670550280388280365 0.010004295439859960809 -5.226292361234363611e-07
4 9.549535102761465607e-11 0.0072467054748629370034
2.265740805092889601e-05
-1.5891417403740180081 0.4938480736359250889 0.049330990309104823244
-0.0036308073545784510204 -0.012168467501132099878 -0.00016594932370266260858
5 2.825345908631354893e-07 0.3552707649709459117
-1.592721551706784977 0.48166390206865000723 0.049163460846716633412
-0.0035287723306552309585 -0.01219974682608557931 -0.00016910795626524249315
5 2.825345908631354893e-07 0.35527074967975702942
0.00046732617030490929307
4.1148395833578952363 -2.8938323061728068453 -0.080043092204059404504
0.0042549773877191511204 0.006534697671907701254 -0.00012233719535540690457
6 8.459715183006415395e-08 0.43765596788571493287
4.119089774477131094 -2.8872942462256898644 -0.080165336328135106125
0.004245402942744468111 0.0065414198811065849687 -0.00012215100047356211078
6 8.459715183006415395e-08 0.4376562090257202473
0.00038925687730393611812
6.3589256477393849565 -7.653288021415167286 -0.12000977499446359442
0.003985370599203661747 0.0035590677039893160206 -0.00022043610541731448703
7 1.2920249163736673626e-08 0.46957663585116591335
6.3629100567525149756 -7.649727796147929304 -0.12023019299387090186
0.0039834472120812329868 0.0035613826786502411278 -0.00022039988214595340028
7 1.2920249163736673626e-08 0.4695793205674148502
0.00016953449859497231466
14.816779495279050138 13.049265812461410263 -0.14351615042000470668
-0.0026245225263081049631 0.002774730265364384104 4.416262654344997005e-05
8 1.5243589003230834323e-08 0.7813355837717117843
14.814154683311180349 13.052040295401360126 -0.14347198499748289868
-0.002625101393275708784 0.0027742356008832688187 4.416821810149910185e-05
8 1.5243589003230834323e-08 0.7813388398513013378
0.000164587904124493665
29.564459991843019537 -4.5824598513731222837 -0.5870359532621901577
0.0004648344125208179762 0.0031282868879460171488 -7.5042704502708602616e-05
29.564924658285640646 -4.579331535234244299 -0.5871109926822926095
0.00046449847307956888343 0.003128345390031967918 -7.5036135696161668576e-05

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions examples/symba_swifter_comparison/8pl_16tp_encounters/tp.in
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
16
101
-0.0658187108448175795 0.30391138014159824188 0.030872485461978960153
-0.030537616761930286291 -0.0049297226604189817514 0.0026371811668407158825
-0.09859055695785905182 0.2975290300646933339 0.03335708456145129036
-0.029750083068855306956 -0.0078122718370876240157 0.0023293874953380202045
102
-0.065864832257480881994 0.3038652587289349949 0.030872485461978960153
-0.035744715705948587603 -0.0049297226604189817514 0.0026371811668407158825
-0.09863667837052235432 0.29748290865203008693 0.03335708456145129036
-0.034957182012873608268 -0.0078122718370876240157 0.0023293874953380202045
103
-0.6526399503364792576 -0.30651935535365792962 0.033456491497379246824
0.014807065041004032965 -0.0184014319837384685 -0.0007407193515014080928
-0.6439245854659476631 -0.32479782779646521051 0.032702713983447248558
0.0153169432007213678765 -0.018153139924556138673 -0.0007667345025597138231
104
-0.65275437091742372075 -0.30663377593460228177 0.033456491497379246824
0.0021125976303132450868 -0.0184014319837384685 -0.0007407193515014080928
-0.6440390060468921263 -0.32491224837740956266 0.032702713983447248558
0.002622475790030579998 -0.018153139924556138673 -0.0007667345025597138231
105
0.58052308875528702004 -0.8331397763444912119 3.7646553415201541957e-05
0.020730998066553867065 0.009770187318278569788 -5.1179589633921335467e-07
0.59427697124197276235 -0.8232523083817967491 3.7129329104855261984e-05
0.020564990514662154913 0.010004295439859960809 -5.226292361234363611e-07
106
0.58040263294340799227 -0.83326023215637023966 3.7646553415201541957e-05
0.0069421175980061153657 0.009770187318278569788 -5.1179589633921335467e-07
0.5941565154300937346 -0.82337276419367577684 3.7129329104855261984e-05
0.0067761100461144049487 0.010004295439859960809 -5.226292361234363611e-07
107
-1.5891096979602641337 0.49388011604967890777 0.049330990309104823244
-0.00055132825635455804184 -0.012168467501132099878 -0.00016594932370266260858
-1.5926895092930311026 0.48169594448240382611 0.049163460846716633412
-0.00044929323243133797994 -0.01219974682608557931 -0.00016910795626524249315
108
-1.5891737827877718825 0.49381603122217127 0.049330990309104823244
-0.0067102864528023435653 -0.012168467501132099878 -0.00016594932370266260858
-1.5927535941205388514 0.48163185965489618834 0.049163460846716633412
-0.006608251428879123937 -0.01219974682608557931 -0.00016910795626524249315
109
4.1155004823659924185 -2.893171407164709663 -0.080043092204059404504
0.0411371945893665783 0.006534697671907701254 -0.00012233719535540690457
4.119750673485228276 -2.8866333472175926822 -0.080165336328135106125
0.041127620144391897894 0.0065414198811065849687 -0.00012215100047356211078
110
4.114178684349798054 -2.8944932051809040274 -0.080043092204059404504
-0.032627239813928281265 0.006534697671907701254 -0.00012233719535540690457
4.118428875469033912 -2.8879551452337870465 -0.080165336328135106125
-0.032636814258902961672 0.0065414198811065849687 -0.00012215100047356211078
111
6.3594761400945154506 -7.652737529060036792 -0.12000977499446359442
0.02609853948273724994 0.0035590677039893160206 -0.00022043610541731448703
6.3634605491076454697 -7.64917730379279881 -0.12023019299387090186
0.026096616095614821179 0.0035613826786502411278 -0.00022039988214595340028
112
6.3583751553842544624 -7.65383851377029778 -0.12000977499446359442
-0.01812779828432992818 0.0035590677039893160206 -0.00022043610541731448703
6.3623595643973844815 -7.650278288503059798 -0.12023019299387090186
-0.01812972167145235694 0.0035613826786502411278 -0.00022039988214595340028
113
14.817019253266252576 13.049505570448612701 -0.14351615042000470668
0.010470241012353788054 0.002774730265364384104 4.416262654344997005e-05
14.814394441298382787 13.052280053388562564 -0.14347198499748289868
0.010469662145386185101 0.0027742356008832688187 4.416821810149910185e-05
114
14.8165397372918477 13.049026054474207825 -0.14351615042000470668
-0.015719286064969997113 0.002774730265364384104 4.416262654344997005e-05
14.813914925323977911 13.051800537414157688 -0.14347198499748289868
-0.015719864931937603536 0.0027742356008832688187 4.416821810149910185e-05
115
29.564692754289236376 -4.5822270889269072214 -0.5870359532621901577
0.014900470225798949711 0.0031282868879460171488 -7.5042704502708602616e-05
29.565157420731857485 -4.579098772788029237 -0.5871109926822926095
0.014900134286357700347 0.003128345390031967918 -7.5036135696161668576e-05
116
29.564227229396802699 -4.582692613819337346 -0.5870359532621901577
-0.013970801400757312458 0.0031282868879460171488 -7.5042704502708602616e-05
29.564691895839423808 -4.5795642976804593616 -0.5871109926822926095
-0.0139711373401985618214 0.003128345390031967918 -7.5036135696161668576e-05
16 changes: 8 additions & 8 deletions src/symba/symba_encounter_check.f90
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@ module function symba_encounter_check_tp(self, system, dt, irec) result(lany_enc
logical, dimension(:,:), allocatable :: lencounter, loc_lvdotr

associate(tp => self, ntp => self%nbody, pl => system%pl, npl => system%pl%nbody)
allocate(lencounter(npl, ntp), loc_lvdotr(npl, ntp))
allocate(lencounter(ntp, npl), loc_lvdotr(ntp, npl))
lencounter(:,:) = .false.

do j = 1, ntp
do i = 1, npl
xr(:) = tp%xh(:, j) - pl%xh(:, i)
vr(:) = tp%vh(:, j) - pl%vh(:, i)
call symba_encounter_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), pl%rhill(i), 0.0_DP, dt, irec, lencounter(i,j), loc_lvdotr(i,j))
do j = 1, npl
do i = 1, ntp
xr(:) = tp%xh(:, i) - pl%xh(:, j)
vr(:) = tp%vh(:, i) - pl%vh(:, j)
call symba_encounter_check_one(xr(1), xr(2), xr(3), vr(1), vr(2), vr(3), pl%rhill(j), 0.0_DP, dt, irec, lencounter(i,j), loc_lvdotr(i,j))
end do
end do

Expand All @@ -156,8 +156,8 @@ module function symba_encounter_check_tp(self, system, dt, irec) result(lany_enc
pltpenc_list%status(1:nenc) = ACTIVE
pltpenc_list%level(1:nenc) = irec
pltpenc_list%lvdotr(1:nenc) = pack(loc_lvdotr(:,:), lencounter(:,:))
pltpenc_list%index1(1:nenc) = pack(spread([(i, i = 1, npl)], dim=2, ncopies=ntp), lencounter(:,:))
pltpenc_list%index2(1:nenc) = pack(spread([(j, j = 1, ntp)], dim=1, ncopies=npl), lencounter(:,:))
pltpenc_list%index1(1:nenc) = pack(spread([(i, i = 1, npl)], dim=1, ncopies=ntp), lencounter(:,:))
pltpenc_list%index2(1:nenc) = pack(spread([(i, i = 1, ntp)], dim=2, ncopies=npl), lencounter(:,:))
select type(pl)
class is (symba_pl)
pl%lencounter(:) = .false.
Expand Down
6 changes: 3 additions & 3 deletions src/symba/symba_kick.f90
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module subroutine symba_kick_getacch_pl(self, system, param, t, lbeg)
select type(system)
class is (symba_nbody_system)
associate(pl => self, cb => system%cb, plplenc_list => system%plplenc_list, nplplenc => system%plplenc_list%nenc)
call helio_kick_getacch_pl(pl, system, param, t, lbeg)
! Remove accelerations from encountering pairs
do k = 1, nplplenc
associate(i => plplenc_list%index1(k), j => plplenc_list%index2(k))
Expand All @@ -39,7 +40,6 @@ module subroutine symba_kick_getacch_pl(self, system, param, t, lbeg)
!end if
end associate
end do
call helio_kick_getacch_pl(pl, system, param, t, lbeg)
end associate
end select

Expand Down Expand Up @@ -68,6 +68,7 @@ module subroutine symba_kick_getacch_tp(self, system, param, t, lbeg)
select type(system)
class is (symba_nbody_system)
associate(tp => self, cb => system%cb, pl => system%pl, pltpenc_list => system%pltpenc_list, npltpenc => system%pltpenc_list%nenc)
call helio_kick_getacch_tp(tp, system, param, t, lbeg)
! Remove accelerations from encountering pairs
do k = 1, npltpenc
associate(i => pltpenc_list%index1(k), j => pltpenc_list%index2(k))
Expand All @@ -86,7 +87,6 @@ module subroutine symba_kick_getacch_tp(self, system, param, t, lbeg)
end IF
end associate
end do
call helio_kick_getacch_tp(tp, system, param, t, lbeg)
end associate
end select
return
Expand Down Expand Up @@ -142,7 +142,7 @@ module subroutine symba_kick_pltpenc(self, system, dt, irec, sgn)
else
lgoodlevel = (pl%levelg(i) >= irm1) .and. (tp%levelg(j) >= irm1)
end if
if ((self%status(i) == ACTIVE) .and. lgoodlevel) then
if ((self%status(k) == ACTIVE) .and. lgoodlevel) then
if (isplpl) then
ri = ((pl%rhill(i) + pl%rhill(j))**2) * (RHSCALE**2) * (RSHELL**(2*irecl))
rim1 = ri * (RSHELL**2)
Expand Down

0 comments on commit e32e3d6

Please sign in to comment.