From 007c4b584d05deac365822e9a2479543d74c1436 Mon Sep 17 00:00:00 2001 From: Brendan Keith Date: Thu, 7 Mar 2024 19:14:21 -0500 Subject: [PATCH] README and ex 1 --- README.md | 5 ++-- examples/01_basic_mann_parameters_fit.py | 33 +++++++++++------------- setup.py | 4 +-- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 63f2fe5..b962fe0 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,10 @@ The code is based on the original work of Jacob Mann in [1994](https://doi.org/10.1017/S0022112094001886) and [1998](https://doi.org/10.1016/S0266-8920(97)00036-2) -as well as in the deep-learning enhancement developed by Keith et al in [this 2021 publication](https://arxiv.org/pdf/2107.11046.pdf). +as well as in the deep-learning enhancement developed by Keith et al. in [this 2021 publication](https://arxiv.org/pdf/2107.11046.pdf). ## Basic Usage - See the ``/examples/`` folder for baselines from the paper and for examples of the many functionalities of the package. ## Development Installation Instructions @@ -25,5 +24,5 @@ Docs are in the ``/docs/`` folder. Make sure the dependencies listed in ``./requ Run ``make html`` to generate html pages in the ``/docs/build/html`` folder, which can be hosted locally with ``python -m http.server ``. -## Attribution + diff --git a/examples/01_basic_mann_parameters_fit.py b/examples/01_basic_mann_parameters_fit.py index 184be44..e1e9424 100644 --- a/examples/01_basic_mann_parameters_fit.py +++ b/examples/01_basic_mann_parameters_fit.py @@ -1,19 +1,19 @@ r""" -=================== -Basic Mann Model Fit -=================== +=============================== +Example 1: Basic Mann Model Fit +=============================== -This example demonstrates the a simple configuration of ``DRDMannTurb`` to spectra fitting while using the Mann model as the eddy lifetime function under the Kaimal one-point spectra. +This example demonstrates fitting the Mann model eddy lifetime function to the Kaimal one-point spectra. -For reference, the full Mann eddy lifetime function is given by +For reference, the Mann eddy lifetime function is given by .. math:: - \tau^{\mathrm{Mann}}(k)=\frac{(k L)^{-\frac{2}{3}}}{\sqrt{{ }_2 F_1\left(1 / 3,17 / 6 ; 4 / 3 ;-(k L)^{-2}\right)}} + \tau^{\mathrm{Mann}}(k)=\frac{(k L)^{-\frac{2}{3}}}{\sqrt{{ }_2 F_1\left(1 / 3,17 / 6 ; 4 / 3 ;-(k L)^{-2}\right)}}\,. -and the Kaimal one-point spectra. This set of models has classically been most useful for flat homogeneous terrains. +This set of models it widely used for flat, homogeneous terrains. -Also, the resulting fitting can be used directly to generate a 3D Mann fluctuation field, as demonstrated in our wind generation example. +``drdmannturb`` can also be used directly to generate the corresponding 3D turbulence field, as demonstrated in Examples 8 and 9. """ @@ -41,8 +41,7 @@ torch.set_default_tensor_type("torch.cuda.FloatTensor") ####################################################################################### -# Set up physical parameters and domain associated with the Kaimal spectrum. We perform the spectra fitting over the :math:`k_1` space :math:`[10^{{-1}}, 10^2]` -# with 20 points. +# Set up physical parameters and domain. We perform the spectra fitting over the :math:`k_1 z` space :math:`[10^{{-1}}, 10^2]` with 20 points. zref = 40 # reference height @@ -61,13 +60,10 @@ # ``CalibrationProblem`` Construction # ----------------------------------- # The following cell defines the ``CalibrationProblem`` using default values -# for the ``NNParameters`` and ``LossParameters`` dataclasses. Importantly, -# these data classes are not necessary, see their respective documentations for the default values. -# The current set-up involves using the Mann model for the eddy lifetime function, meaning no -# neural network is used in learning the :math:`\tau` function. Additionally, the physical parameters -# are taken from the reference values for the Kaimal spectra. Finally, in this scenario the regression -# occurs as an MSE fit to the spectra, which are generated from Mann turbulence (i.e., a synthetic data fit). -# The ``EddyLifetimeType.MANN`` argument determines the type of eddy lifetime function to use. +# for the ``NNParameters`` and ``LossParameters`` dataclasses. +# Notice that ``EddyLifetimeType.MANN`` specifies the Mann model for the eddy lifetime +# function, meaning no neural network is used in learning the :math:`\tau` function. +# Thus, we only learn the parameters :math:`L`, :math:`\Gamma`, and :math:`\sigma`. pb = CalibrationProblem( nn_params=NNParameters(), prob_params=ProblemParameters(eddy_lifetime=EddyLifetimeType.MANN, nepochs=2), @@ -100,7 +96,8 @@ # which only has a CPU implementation through ``Scipy``. When using this function # with a neural network task, consider either learning this function as well or # using a linear approximation from your data that provides a GPU kernel for -# fast evaluation of a similar model. See the final example in the collection where a linear regression is used in log-log space to generate this. +# fast evaluation of a similar model. See the Example 7, where linear regression +# is used in log-log space to generate this. # # Having the necessary components, the model is "calibrated" (fit) to the provided spectra # and we conclude with a plot. diff --git a/setup.py b/setup.py index 1d5eb6a..e0515a8 100644 --- a/setup.py +++ b/setup.py @@ -4,8 +4,8 @@ name="drdmannturb", version="0.1.0", description="Mann turbulence modelling", - url="https://github.com/mjachi/WindGenerator", - author="Alexey Izmailov, Matthew Meeker based on code by Brendan Keith et al", + url="https://github.com/METHODS-Group/DRDMannTurb", + author="Alexey Izmailov, Matthew Meeker based on code by Brendan Keith et al.", author_email="alizma@brown.edu, matthew_meeker@brown.edu", license="BSD 2-clause", packages=["drdmannturb"],