\n",
"\n",
" Notebook Version 2: This notebook has been updated to reflect changes made to the package DifferentialMobilityAnalyzers.jl to work with the Julia v1 series (tested with Julia 1.1.0). To read the original supplement published with the paper please switch to v1.0.0 of the package DifferentialMobilityAnalyzers.jl and/or download the virtual machine on zenodo.org which contains a complete installation that works with Julia 0.6.4 \n",
"\n",
"This notebook demonstrates how to use external FORTRAN code to compute the convolution matrix. The notebook is a supplement to the manuscript \n",
"\n",
"Petters, M. D. (2018) A language to simplify interpretation of differential mobility analyzer response functions, Aerosol Science & Technology. "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
" \n"
],
"text/plain": [
"HTML{String}(\" \\n\")"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"HTML{String}(\"\")"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"HTML{String}(\"\")"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
" \n"
],
"text/plain": [
"HTML{String}(\" \\n\")"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"using Plots, Plots.PlotMeasures, DataFrames, DifferentialMobilityAnalyzers\n",
"plotlyjs(); "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Compute Convolution Matrix For DMA δ\n",
"δ.Ω is defined in src/dmafunctions.jl and includes diffusional broadening. Alternative functions for Ω can easily be either added to the package or defined and passed to the T = ... statement"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 1.374549 seconds (8.50 M allocations: 257.071 MiB, 4.55% gc time)\n"
]
}
],
"source": [
"t,p = 296.15, 1e5 # Temperature [K], Pressure [Pa]\n",
"qsa,β = 1.66e-5, 1/5 # Qsample [m3 s-1], Sample-to-sheath ratio,\n",
"r₁,r₂,l = 9.37e-3,1.961e-2,0.44369 # DMA geometry [m]\n",
"leff = 13.0 # DMA effective diffusion length [m]\n",
"m = 6 # Upper number of charges\n",
"Λ = DMAconfig(t,p,qsa,qsa/β,r₁,r₂,l,leff,:-,m,:cylindrical) # Specify DMA with negative polarity\n",
"bins,z₁,z₂ = 128, dtoz(Λ,1000e-9), dtoz(Λ,10e-9) # bins, upper, lower mobility limit\n",
"δ = setupDMA(Λ, z₁, z₂, bins); # Compute matrices internally\n",
"\n",
"T = (zˢ,k,Λ,δ) -> δ.Ω(Λ,δ.Z,zˢ/k).*δ.Tc(k,δ.Dp).*δ.Tl(Λ,δ.Dp); \n",
"@time 𝐀₁ = (hcat(map(zˢ->Σ(k->T(zˢ,k,Λ,δ),Λ.m),δ.Z)...))'; # compute matrix explicitly, 𝐀₁ == δ.A"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Direct Call of FORTRAN Function \n",
"Instead of defining alterante formulations of Ω in Julia, existing FORTRAN (or C) code can be called directly from Julia. This enables seamless integration of numerically derived transfer functions, e.g. through Monte-Carlo analysis, with the DMA language described in this work. A step-by-step tutorial with a simple example is provided.\n",
"\n",
"### 1. Write/Inspect FUNCTION\n",
"The Knutson and Whitby (1975) transfer function.\n",
"\n",
"