MPTRAC
sedi.c
Go to the documentation of this file.
1/*
2 This file is part of MPTRAC.
3
4 MPTRAC is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 MPTRAC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with MPTRAC. If not, see <http://www.gnu.org/licenses/>.
16
17 Copyright (C) 2013-2026 Forschungszentrum Juelich GmbH
18*/
19
25#include "mptrac.h"
26
27/* ------------------------------------------------------------
28 Functions...
29 ------------------------------------------------------------ */
30
32void usage(
33 void);
34
35/* ------------------------------------------------------------
36 Main...
37 ------------------------------------------------------------ */
38
39int main(
40 int argc,
41 char *argv[]) {
42
43 /* Print usage information... */
44 USAGE;
45
46 /* Check arguments... */
47 if (argc < 5)
48 ERRMSG("Missing or invalid command-line arguments.\n\n"
49 "Usage: sedi <p> <T> <r_p> <rho_p>\n\n" "Use -h for full help.");
50
51 /* Read arguments... */
52 const double p = atof(argv[1]);
53 const double T = atof(argv[2]);
54 const double r_p = atof(argv[3]);
55 const double rho_p = atof(argv[4]);
56
57 /* Calculate sedimentation velocity... */
58 const double vs = sedi(p, T, r_p, rho_p);
59
60 /* Density of dry air [kg / m^3]... */
61 const double rho = 100. * p / (RA * T);
62
63 /* Dynamic viscosity of air [kg / (m s)]... */
64 const double eta = 1.8325e-5 * (416.16 / (T + 120.)) * pow(T / 296.16, 1.5);
65
66 /* Particle Reynolds number... */
67 const double Re = 2e-6 * r_p * vs * rho / eta;
68
69 /* Write output... */
70 printf(" p= %g hPa\n", p);
71 printf(" T= %g K\n", T);
72 printf(" r_p= %g microns\n", r_p);
73 printf("rho_p= %g kg/m^3\n", rho_p);
74 printf("rho_a= %g kg/m^3\n", RHO(p, T));
75 printf(" v_s= %g m/s\n", vs);
76 printf(" Re= %g\n", Re);
77
78 return EXIT_SUCCESS;
79}
80
81/*****************************************************************************/
82
84void usage(
85 void) {
86
87 printf("\nMPTRAC sedi tool.\n\n");
88 printf
89 ("Calculate sedimentation velocity for aerosol or cloud particles.\n");
90 printf("\n");
91 printf("Usage:\n");
92 printf(" sedi <p> <T> <r_p> <rho_p>\n");
93 printf("\n");
94 printf("Arguments:\n");
95 printf(" <p> Pressure [hPa].\n");
96 printf(" <T> Temperature [K].\n");
97 printf(" <r_p> Particle radius [um].\n");
98 printf(" <rho_p> Particle density [kg/m3].\n");
99 printf("\nFurther information:\n");
100 printf(" Manual: https://slcs-jsc.github.io/mptrac/\n");
101}
double sedi(const double p, const double T, const double rp, const double rhop)
Calculates the sedimentation velocity of a particle in air.
Definition: mptrac.c:10817
MPTRAC library declarations.
#define RA
Specific gas constant of dry air [J/(kg K)].
Definition: mptrac.h:306
#define ERRMSG(...)
Print an error message with contextual information and terminate the program.
Definition: mptrac.h:2102
#define USAGE
Print usage information on -h or --help.
Definition: mptrac.h:1909
#define RHO(p, t)
Compute density of air.
Definition: mptrac.h:1657
int main(int argc, char *argv[])
Definition: sedi.c:39
void usage(void)
Print command-line help.
Definition: sedi.c:84