Skip to content

Commit 05a08ce

Browse files
authored
Merge pull request #53 from OceanParcels/minor_kernel_updates
Minor kernel updates
2 parents 6643291 + 2201a72 commit 05a08ce

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

plasticparcels/kernels.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ def SettlingVelocity(particle, fieldset, time):
166166
particle_density = particle.plastic_density
167167

168168
# Compute the kinematic viscosity of seawater
169-
water_dynamic_viscosity = 4.2844E-5 + (1 / ((0.156 * (temperature + 64.993) ** 2) - 91.296)) # Eq. (26) from [2]
169+
water_dynamic_viscosity = 4.2844E-5 + (1. / ((0.156 * (temperature + 64.993) ** 2) - 91.296)) # Eq. (26) from [2]
170170
A = 1.541 + 1.998E-2 * temperature - 9.52E-5 * temperature ** 2 # Eq. (28) from [2]
171171
B = 7.974 - 7.561E-2 * temperature + 4.724E-4 * temperature ** 2 # Eq. (29) from [2]
172-
seawater_dynamic_viscosity = water_dynamic_viscosity * (1 + A * seawater_salinity + B * seawater_salinity ** 2) # Eq. (27) from [2]
172+
seawater_dynamic_viscosity = water_dynamic_viscosity * (1. + A * seawater_salinity + B * seawater_salinity ** 2) # Eq. (27) from [2]
173173
seawater_kinematic_viscosity = seawater_dynamic_viscosity / seawater_density # Eq. (25) from [2]
174174

175175
# Compute the density difference of the particle
@@ -182,7 +182,7 @@ def SettlingVelocity(particle, fieldset, time):
182182
if dimensionless_diameter > 5E9: # "The boundary layer around the sphere becomes fully turbulent, causing a reduction in drag and an increase in settling velocity" - [1]
183183
dimensionless_velocity = 265000. # Set a maximum dimensionless settling velocity
184184
elif dimensionless_diameter < 0.05: # "At values of D_* less than 0.05, (9) deviates signficantly ... from Stokes' law and (8) should be used." - [1]
185-
dimensionless_velocity = (dimensionless_diameter ** 2.) / 5832 # Using Eq. (8) in [1]
185+
dimensionless_velocity = (dimensionless_diameter ** 2.) / 5832. # Using Eq. (8) in [1]
186186
else:
187187
dimensionless_velocity = 10. ** (-3.76715 + (1.92944 * math.log10(dimensionless_diameter)) - (0.09815 * math.log10(dimensionless_diameter) ** 2.) - (
188188
0.00575 * math.log10(dimensionless_diameter) ** 3.) + (0.00056 * math.log10(dimensionless_diameter) ** 4.)) # Using Eq. (9) in [1]
@@ -271,10 +271,10 @@ def Biofouling(particle, fieldset, time):
271271
initial_settling_velocity = particle.settling_velocity # settling velocity [m s-1]
272272

273273
# Compute the seawater dynamic viscosity and kinematic viscosity
274-
water_dynamic_viscosity = 4.2844E-5 + (1 / ((0.156 * (temperature + 64.993) ** 2) - 91.296)) # Eq. (26) from [2]
274+
water_dynamic_viscosity = 4.2844E-5 + (1. / ((0.156 * (temperature + 64.993) ** 2) - 91.296)) # Eq. (26) from [2]
275275
A = 1.541 + 1.998E-2 * temperature - 9.52E-5 * temperature ** 2 # Eq. (28) from [2]
276276
B = 7.974 - 7.561E-2 * temperature + 4.724E-4 * temperature ** 2 # Eq. (29) from [2]
277-
seawater_dynamic_viscosity = water_dynamic_viscosity * (1 + A * seawater_salinity + B * seawater_salinity ** 2) # Eq. (27) from [2]
277+
seawater_dynamic_viscosity = water_dynamic_viscosity * (1. + A * seawater_salinity + B * seawater_salinity ** 2) # Eq. (27) from [2]
278278
seawater_kinematic_viscosity = seawater_dynamic_viscosity / particle.seawater_density # Eq. (25) from [2]
279279

280280
# Compute the algal growth component
@@ -406,10 +406,10 @@ def PolyTEOS10_bsq(particle, fieldset, time):
406406
SA = fieldset.absolute_salinity[time, particle.depth, particle.lat, particle.lon]
407407
CT = fieldset.conservative_temperature[time, particle.depth, particle.lat, particle.lon]
408408

409-
SAu = 40 * 35.16504 / 35
410-
CTu = 40
411-
Zu = 1e4
412-
deltaS = 32
409+
SAu = 40. * 35.16504 / 35.
410+
CTu = 40.
411+
Zu = 1.0e+04
412+
deltaS = 32.
413413
R000 = 8.0189615746e+02
414414
R100 = 8.6672408165e+02
415415
R200 = -1.7864682637e+03
@@ -589,11 +589,11 @@ def checkThroughBathymetry(particle, fieldset, time):
589589
particle_ddepth = fieldset.z_start - particle.depth # noqa # Stick particle to surface
590590
elif potential_depth > bathymetry_local:
591591
particle_ddepth = bathymetry_local - particle.depth # noqa # Stick particle at bottom of ocean
592-
elif particle.depth > 100 and potential_depth > (bathymetry_local*0.99): # for deeper particles; since bathymetry can be quite rough (and is interpolated linearly) look at the 99% value instead
592+
elif particle.depth > 100. and potential_depth > (bathymetry_local*0.99): # for deeper particles; since bathymetry can be quite rough (and is interpolated linearly) look at the 99% value instead
593593
particle_ddepth = bathymetry_local*0.99 - particle.depth # noqa # Stick particle at the 99% point
594594

595-
elif potential_depth > 3900: # If particle >3.9km deep, stick it there
596-
particle_ddepth = 3900 - particle.depth # noqa
595+
elif potential_depth > 3900.: # If particle >3.9km deep, stick it there
596+
particle_ddepth = 3900. - particle.depth # noqa
597597

598598

599599

@@ -621,17 +621,17 @@ def checkErrorThroughSurface(particle, fieldset, time):
621621
622622
Description
623623
----------
624-
Kernel to delete a particle if it goes through the surface.
624+
Kernel to place a particle back on the surface if it goes through the surface.
625625
626626
Kernel Requirements
627627
----------
628628
Order of Operations:
629629
This kernel should be performed after all other movement kernels, as it is an error kernel.
630630
"""
631631
if particle.state == StatusCode.ErrorThroughSurface:
632-
# particle_ddepth = - particle.depth # Set so that final depth = 0 # TODO why not use this instead of delete?
633-
# particle.state = StatusCode.Success
634-
particle.delete()
632+
particle_ddepth = 0. # Set the summed displacement to 0.
633+
particle_ddepth += fieldset.z_start - particle.depth # Set ddepth so that final depth is the ocean surface
634+
particle.state = StatusCode.Success
635635

636636

637637
def deleteParticle(particle, fieldset, time):

0 commit comments

Comments
 (0)