-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsediment.py
104 lines (82 loc) · 3.01 KB
/
sediment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
from pint import UnitRegistry
ureg = UnitRegistry()
Q_ = ureg.Quantity
@ureg.wraps(
ureg.gram / ureg.cm**3,
(ureg.gram, ureg.gram, ureg.gram / ureg.cm**3, ureg.gram / ureg.cm**3, None),
)
def drybulkdens(
water_mass,
unadjusted_dry_sediment_mass,
water_density=Q_(1, "g/cm**3"),
sediment_density=Q_(2.65, "g/cm**3"),
salinity=35,
):
"""Compute dry bulk density
Parameters
----------
water_mass :
Water mass, with units as specified. If no units specified, defaults to gram / centimeter ** 3
unadjusted_dry_sediment_mass
Dry sediment mass (unadjusted for dried salts), with units as specified. If no units specified, defaults to gram / centimeter ** 3
water_density : pint.util.Quantity, default 1 gram / centimeter ** 3
Water density
sediment_density : pint.util.Quantity, default 2.65 gram / centimeter ** 3
Sediment density
salinity : float, default 35
Salinity
Returns
-------
pint.util.Quantity
Dry bulk density in gram / centimeter ** 3
"""
dry_sediment_mass = adjust_mass_for_salt(
water_mass, salinity, unadjusted_dry_sediment_mass
)
n = porosity(water_mass, water_density, dry_sediment_mass, sediment_density)
return (1 - n) * sediment_density
@ureg.wraps(
ureg.gram / ureg.cm**3,
(ureg.gram, ureg.gram, ureg.gram / ureg.cm**3, ureg.gram / ureg.cm**3, None),
)
def wetbulkdens(
water_mass,
unadjusted_dry_sediment_mass,
water_density=Q_(1, "g/cm**3"),
sediment_density=Q_(2.65, "g/cm**3"),
salinity=35,
):
"""Compute wet bulk density
Parameters
----------
water_mass :
Water mass, with units as specified. If no units specified, defaults to gram / centimeter ** 3
unadjusted_dry_sediment_mass
Dry sediment mass (unadjusted for dried salts), with units as specified. If no units specified, defaults to gram / centimeter ** 3
water_density : pint.util.Quantity, default 1 gram / centimeter ** 3
Water density
sediment_density : pint.util.Quantity, default 2.65 gram / centimeter ** 3
Sediment density
salinity : float, default 35
Salinity
Returns
-------
pint.util.Quantity
Wet bulk density in gram / centimeter ** 3
"""
dry_sediment_mass = adjust_mass_for_salt(
water_mass, salinity, unadjusted_dry_sediment_mass
)
return (dry_sediment_mass + water_mass) / (
dry_sediment_mass / sediment_density + water_mass / water_density
)
def adjust_mass_for_salt(water_mass, salinity, unadjusted_dry_sediment_mass):
salt_mass = water_mass * salinity / 1000
return unadjusted_dry_sediment_mass - salt_mass
def porosity(water_mass, water_density, dry_sediment_mass, sediment_density):
return (water_mass / water_density) / (
dry_sediment_mass / sediment_density + water_mass / water_density
)
# print(Q_(1, "g/cm**3"))
# print(wetbulkdens(1 * ureg.gram, 2 * ureg.gram, salinity=20))
# print(drybulkdens(1, 2 * ureg.gram, salinity=20))