Skip to content

Commit d263405

Browse files
committed
feat: Remove some comments in forces.F90
Also, tried to fix the systematic problem in V1mplicit
1 parent 1b70623 commit d263405

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/forces.F90

+8-6
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ function dydt_explicit_v1 (t, y) result(dydt)
132132
end do
133133
!$OMP END DO
134134
!$OMP END PARALLEL
135-
! if (any(particles_hexit(1:Nactive) .ne. 0)) particles_hexit(0) = 1
136135
end function dydt_explicit_v1
137136

138137
function dydt_implicit_v1 (t, y) result(dydt) ! Tienen un error sistemático que no detecto aún
@@ -148,7 +147,7 @@ function dydt_implicit_v1 (t, y) result(dydt) ! Tienen un error sistemático que
148147
real(kind=8) :: rcm(2), vcm(2), raux(0:Nboulders,2), vaux(0:Nboulders,2)
149148
real(kind=8) :: omega, omega2, omegadot, inertia, angmom
150149
integer(kind=4) :: i, ineqs, particle_i
151-
real(kind=8) :: dummy_real2(2)
150+
real(kind=8) :: dummy_real2(2), aux_real
152151

153152
dydt = cero
154153

@@ -166,14 +165,19 @@ function dydt_implicit_v1 (t, y) result(dydt) ! Tienen un error sistemático que
166165
end do
167166
rcm = rcm / asteroid_mass ! rcm = sum_i m_i * r_i / M
168167
vcm = vcm / asteroid_mass ! vcm = sum_i m_i * v_i / M
168+
if (sqrt(sum(rcm * rcm)) < error_tolerance) rcm = cero ! Avoid numerical errors
169+
if (sqrt(sum(vcm * vcm)) < error_tolerance) vcm = cero ! Avoid numerical errors
169170
! Calculate angmom and inertia
171+
aux_real = cero
170172
angmom = cero
171173
inertia = cero
172174
do i = 0, Nboulders
173175
raux(i,:) = rib(i,:) - rcm
174176
vaux(i,:) = vib(i,:) - vcm
177+
! aux_real = 0.4d0 * mass_ast_arr(i) * radius_ast_arr(i)**2 ! Inertia Sphere
175178
angmom = angmom + mass_ast_arr(i) * cross2D(raux(i,:), vaux(i,:)) ! Traslacional
176-
inertia = inertia + mass_ast_arr(i) * sum(raux(i,:) * raux(i,:)) ! Inercia
179+
! angmom = angmom + aux_real * cross2D(raux(i,:), vaux(i,:))/sum(raux(i,:) * raux(i,:)) ! Rotacional (Sphere)
180+
inertia = inertia + aux_real + mass_ast_arr(i) * sum(raux(i,:) * raux(i,:)) ! Sphere + Steiner
177181
end do
178182
!! Get Omega from L/I
179183
omega = angmom / inertia
@@ -218,7 +222,7 @@ function dydt_implicit_v1 (t, y) result(dydt) ! Tienen un error sistemático que
218222
dydt(ineqs+3) = -omega2 * raux(i,1) - omegadot * raux(i,2) ! a_i = -w^2 * r_i + dw/dt * (-ry,rx)
219223
dydt(ineqs+4) = -omega2 * raux(i,2) + omegadot * raux(i,1) ! a_i = -w^2 * r_i + dw/dt * (-ry,rx)
220224
end do
221-
! if (any(particles_hexit(1:Nactive) .ne. 0)) particles_hexit(0) = 1
225+
! print*, t, angmom/asteroid_angmom, inertia/asteroid_inertia, omega/asteroid_omega
222226
end function dydt_implicit_v1
223227

224228
function dydt_explicit_v2 (t, y) result(dydt)
@@ -288,7 +292,6 @@ function dydt_explicit_v2 (t, y) result(dydt)
288292
end do
289293
!$OMP END DO
290294
!$OMP END PARALLEL
291-
! if (any(particles_hexit(1:Nactive) .ne. 0)) particles_hexit(0) = 1
292295
end function dydt_explicit_v2
293296

294297
function dydt_implicit_v2 (t, y) result(dydt)
@@ -359,7 +362,6 @@ function dydt_implicit_v2 (t, y) result(dydt)
359362
!$OMP END DO
360363
!$OMP END PARALLEL
361364
dydt(2) = domegadt(t, omega) + omegadot
362-
! if (any(particles_hexit(1:Nactive) .ne. 0)) particles_hexit(0) = 1
363365
end function dydt_implicit_v2
364366

365367
function dydt_no_boulders (t, y) result(dydt)

0 commit comments

Comments
 (0)