{"action":"created","issue":{"url":"https://api.github.com/repos/libantioch/antioch/issues/79","labels_url":"https://api.github.com/repos/libantioch/antioch/issues/79/labels{/name}","comments_url":"https://api.github.com/repos/libantioch/antioch/issues/79/comments","events_url":"https://api.github.com/repos/libantioch/antioch/issues/79/events","html_url":"https://github.com/libantioch/antioch/pull/79","id":43655779,"number":79,"title":"Transport","user":{"login":"SylvainPlessis","id":4761614,"avatar_url":"https://avatars.githubusercontent.com/u/4761614?v=3","gravatar_id":"","url":"https://api.github.com/users/SylvainPlessis","html_url":"https://github.com/SylvainPlessis","followers_url":"https://api.github.com/users/SylvainPlessis/followers","following_url":"https://api.github.com/users/SylvainPlessis/following{/other_user}","gists_url":"https://api.github.com/users/SylvainPlessis/gists{/gist_id}","starred_url":"https://api.github.com/users/SylvainPlessis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SylvainPlessis/subscriptions","organizations_url":"https://api.github.com/users/SylvainPlessis/orgs","repos_url":"https://api.github.com/users/SylvainPlessis/repos","events_url":"https://api.github.com/users/SylvainPlessis/events{/privacy}","received_events_url":"https://api.github.com/users/SylvainPlessis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":30,"created_at":"2014-09-23T17:02:53Z","updated_at":"2015-01-13T16:58:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/libantioch/antioch/pulls/79","html_url":"https://github.com/libantioch/antioch/pull/79","diff_url":"https://github.com/libantioch/antioch/pull/79.diff","patch_url":"https://github.com/libantioch/antioch/pull/79.patch"},"body":"This is the transport branch, it contains basically the kinetics theory for the viscosity, thermal conduction and diffusion.  It's pretty big, I'll try to explain it as good as I can.\r\n\r\n#### Big picture\r\n\r\nThis is the fully templated, no virtual method, no vtable lookup version.  \r\nThe big picture is:\r\nthe ```WilkeEvaluator``` contains a ```WilkeMixture``` object which contains ```PhysicalSet``` objects, which is the fork point between the models, a _Mixture_ object (```TransportMixture```, it's templated because it is lighter in terms of template this way, and more general), and a _ThermoEvaluator_ object (typically the NASA polynoms, I'll write on the thermo a little bit).\r\n\r\n#### The fun\r\n\r\nThe fork between the ```PhysicalSet``` and the models is where the fun (horror?) is.  The method I have chosen (well, I didn't really find any other) is to have generic methods and tags to chose the proper one.  The methods are ```void``` so the default is that they are empty, and thus hopefully suppressed by the compiler (and if not, nothing happens anyway).  \r\nThe ```PhysicalSet``` object is built upon the following pattern:\r\n   - a ```SetOrEquation<Model>``` object will properly choose between either just one instantiation of the model (as ```ConstantLewisDiffusivity```) or a set of models (as ```BlottnerViscosity```),\r\n   - the constructor calls the global ```physical_set_initialize``` method, which is tagged and thus, any model not being the default (default is one instantiation of the model or a vector of ```n_species``` of models) can be properly initialize (see for instance the corresponding method in _src/diffusion/include/antioch/molecular_binary_diffusion_utils.h_)\r\n   - then in quite the same idea, ```physical_set_add_model``` methods are defined also, with defaults for a vector of models or one instantiation of the model.\r\n   - the operators.  This is the not-very-elegant part.  I could't find a way to have a few of them, as models require different parameters.  So I have two methods for viscosity and thermal conduction and four for diffusion.  This comes from the description of the system: at the species level, typically one species have one value, thus a method to obtain that value and one method to obtain the vector of values.  The diffusion is quite different in the fact that at the mixture level it's one value per species and at the species level a matrix of species.  The ```ConstantLewisDiffusivity``` actually gives the mixture level value, so the operator corresponding to it has not the same signature that the ```MolecularBinaryDiffusion``` one.  Thus double dose operator.  The corresponding global methods (```physical_set_operator_viscosity/thermal_conduction/diffusion```) are defaulted to nothing, and are explicitely described for each model, using tag.\r\n   - a ```physical_set_reset``` and ```physical_set_delete``` for resetting and the desctuctor, same fashion.\r\n\r\nThe defaults are given in terms of tags, there is this big tagged object:\r\n```\r\n// gives the tag of the model for any interesting\r\n// action, base class so we don't rewrite everything\r\n   template <typename Model, typename Enable = void>\r\n   struct physical_tag_base\r\n   {\r\n        // tag\r\n     typedef default_physical_tag type;\r\n        // kind of set tag\r\n     typedef typename if_else_type<is_physical_set<Model>::value,\r\n                                     default_physical_set_tag,\r\n                                     default_physical_tag\r\n                                   >::type set_type;\r\n        // some models require specific initialization\r\n        // (typically automatic initialization)\r\n     typedef typename if_else_type<is_physical_set<Model>::value,\r\n                                     default_physical_set_tag,\r\n                                     default_physical_tag\r\n                                   >::type init_type;\r\n        // some models require specific initialization\r\n        // but not specific deletion\r\n     typedef typename if_else_type<is_physical_set<Model>::value,\r\n                                     default_physical_set_tag,\r\n                                     default_physical_tag\r\n                                   >::type del_type;\r\n        // for operators, diffusion is special, see comment below\r\n     typedef default_physical_tag viscosity_type;\r\n     typedef default_physical_tag diffusion_species_type;\r\n     typedef default_physical_tag diffusion_mixture_type;\r\n     typedef default_physical_tag thermal_conductivity_type;\r\n   };\r\n```\r\nthat will produced the default method and ensure that if a model do not have a required method defined, it will complain at compile time as the method won't exist.\r\n\r\nAll those templated-tagged-specific methods are declared in files _src/Physics/include/antioch/model_utils_decl.h_ and defined in _src/Physics/include/antioch/model_utils.h_, I just copy/pasted the metaprogramming design (Physics = diffusion || viscosity || thermal_conduction).\r\n\r\nThe parsing is not changed, except that it takes a ```PhysicalSet``` object, and that as typically, kinetics therory objects can be build without the user, they are called in the corresponding ```physical_set_initialize```, the name of the method/file use the word *build* instead of *parse* to notice the difference.\r\n\r\n#### GSL and the spline\r\n\r\nSome models (bimolecular diffusion & kinetics theory viscosity) requires an interpolated value of a surface (the Stockmayer potential).  The spline by default is GSL cspline, thus we have a requirement of GSL.\r\n\r\n#### The thermo\r\n\r\nThis is annoying, there are two very different thermo way of life: the NASA polynomials or statistical thermo.  The last one is needed solely for thermal conduction (and only if not ideal gas).  The thing is that we require Cp to be computed for the Lewis diffusion model, this Cp typically comes from the NASA polynomials, and we have all the different Cvs for thermal conduction, coming from the statistical description.  So I just couldn't find a way of making all models and possibilities happy other than having a reference to a thermo object in the mixture (thus the choice for Lewis, the NASA) and thermo in the ```TransportMixture```, the statistical, for the thermal conduction.  This is weird, kinda annoying, I don't have any better idea.\r\n\r\n#### What's nice\r\n\r\nThis is a pretty nice way of dealing with various models, tags and all, and normally only the required code will be produced.  Thus adding more physics should be painless.\r\n\r\n#### What's annoying\r\n\r\nWell, just look at *test/wilke_mixture_unit.C*... The templates are terrible...  The vectorized version uses typedef to lighten things.\r\n\r\n#### What we'd probably want\r\n\r\nI think we need to put all the mixture equations from the ```WilkeEvaluator``` object into the ```WilkeMixture``` object, so then we can very well use interpolants instead of physical models.  It would require to treat interpolation just like physical models: initialization with some physics, a temperature/pressure interval using tags.  It does not require any change in the design.\r\nNot done yet because I don't have the time to code the interpolation initialization (yet) and I want more opinions than just mine on what interpolation methods/libraries we want."},"comment":{"url":"https://api.github.com/repos/libantioch/antioch/issues/comments/69778136","html_url":"https://github.com/libantioch/antioch/pull/79#issuecomment-69778136","issue_url":"https://api.github.com/repos/libantioch/antioch/issues/79","id":69778136,"user":{"login":"pbauman","id":3051555,"avatar_url":"https://avatars.githubusercontent.com/u/3051555?v=3","gravatar_id":"","url":"https://api.github.com/users/pbauman","html_url":"https://github.com/pbauman","followers_url":"https://api.github.com/users/pbauman/followers","following_url":"https://api.github.com/users/pbauman/following{/other_user}","gists_url":"https://api.github.com/users/pbauman/gists{/gist_id}","starred_url":"https://api.github.com/users/pbauman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pbauman/subscriptions","organizations_url":"https://api.github.com/users/pbauman/orgs","repos_url":"https://api.github.com/users/pbauman/repos","events_url":"https://api.github.com/users/pbauman/events{/privacy}","received_events_url":"https://api.github.com/users/pbauman/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T16:58:56Z","updated_at":"2015-01-13T16:58:56Z","body":"Let's discuss in a couple of hours."}}