Giter VIP home page Giter VIP logo

open-atmos / pypartmc Goto Github PK

View Code? Open in Web Editor NEW
22.0 3.0 8.0 1.48 MB

Python (and C++) interface to PartMC with Jupyter/Python, Julia and Matlab examples

Home Page: https://open-atmos.github.io/PyPartMC/

License: GNU General Public License v3.0

CMake 5.45% Python 31.74% Fortran 28.37% C++ 34.43% Shell 0.01%
atmospheric-modelling atmospheric-physics monte-carlo-simulation particle-system pybind11 python research simulation sundials aerosol-modelling

pypartmc's People

Contributors

jchoi25 avatar jcurtis2 avatar slayoo avatar zdaq12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pypartmc's Issues

fix C++ warnings

here's what is currently reported by the cpplint workflow:

CLANG WARNINGS:

/github/workspace/files/src%2Fpypartmc.cpp:7:10: error: 'pybind11/pybind11.h' file not found [clang-diagnostic-error]
#include "pybind11/pybind11.h"
         ^~~~~~~~~~~~~~~~~~~~~
/github/workspace/files/src%2Fpypartmc.cpp:22:9: warning: function-like macro 'STRINGIFY' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]
#define STRINGIFY(x) #x
        ^
/github/workspace/files/src%2Fpypartmc.cpp:23:9: warning: function-like macro 'MACRO_STRINGIFY' used; consider a 'constexpr' template function [cppcoreguidelines-macro-usage]
#define MACRO_STRINGIFY(x) STRINGIFY(x)
        ^
/github/workspace/files/src%2Fpypartmc.cpp:27:1: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
PYBIND11_MODULE(_PyPartMC, m) {
^
/github/workspace/files/src%2Fpypartmc.cpp:27:26: warning: all parameters should be named in a function [readability-named-parameter]
PYBIND11_MODULE(_PyPartMC, m) {
                         ^
                          /*unused*/  /*unused*/
/github/workspace/files/src%2Fpypartmc.cpp:182:10: warning: variable name 'si' is too short, expected at least 3 characters [readability-identifier-length]
    auto si = m.def_submodule("si", "SI units");
         ^

CPPCHECK WARNINGS:

CMakeLists.txt:143:45: error: syntax error [syntaxError]
foreach(target _PyPartMC)  # TODO: the same for partmclib
                                            ^
PyPartMC%2F__init__.py:5:1: error: syntax error: keyword 'if' is not allowed in global scope [syntaxError]
if (3, 8) <= sys.version_info and platform.system() == 'Windows':
^
clang-tidy-report.txt:14:31: error: Unmatched '{'. Configuration: ''. [syntaxError]
PYBIND11_MODULE(_PyPartMC, m) {
                              ^
setup.py:86:77: error: No pair for character ('). Can't process file. File is either invalid or unicode, which is currently not supported. [syntaxError]
            # Specify the arch if using MSVC generator, but only if it doesn't
                                                                            ^
src%2Fpypartmc.cpp:27:0: style: The function 'PYBIND11_MODULE' is never used. [unusedFunction]

^
nofile:0:0: information: Cppcheck cannot find all the include files (use --check-config for details) [missingInclude]

spec_file i/o improvements

  • in spec_file_read_real_named_array_size: check each line has the same number of elements as time
  • in spec_file_read_real_named_array_data: use input name_size as limit param
  • in spec_file_read_real_named_array: handle max_lines
  • in spec_file_read_line_no_eof: missing deallocate
  • in spec_file_read_line: implement it!
  • in gimmicks::read_arr: check size
  • in gimmicks::zoom: handle errors
  • in gimmicks::first_field_name - remove after initialising GasData with a list, and not JSON?
  • in gimmicks::first_field_name - handle errors
  • in gimmicks::read_str - replace assert(false) with something intuitive & remove unused path

setting kappa for aero species with ions will fail

Looking at the notebook condense.ipynb, it seems to crash if you change some of the values of kappa. I noticed this as I tried to set the values of kappa to the correct values but was met with some surprise.

Appears to have to do with species that have ions specified. For example:

aero_data = ppmc.AeroData(( {"SO4": [1800 * si.kg/si.m**3, 1, 96.0 * si.g/si.mol, 0.00]}, ))

will work. The following will fail where kappa is set to non-zero:

aero_data = ppmc.AeroData(( {"SO4": [1800 * si.kg/si.m**3, 1, 96.0 * si.g/si.mol, 0.65]}, ))

but if I set the number of ions to 0 and set kappa to .65

aero_data = ppmc.AeroData(( {"SO4": [1800 * si.kg/si.m**3, 0, 96.0 * si.g/si.mol, 0.65]}, ))

will work fine.

make cpplint workflow execute only if C++ code was changed

currently if only non-C++ changes are committed, this is reported in a PR:

CLANG WARNINGS:

error: no input files [clang-diagnostic-error]
error: no such file or directory: '/github/workspace/files/*.cpp' [clang-diagnostic-error]
error: unable to handle compilation, expected exactly one compiler job in '' [clang-diagnostic-error]

CPPCHECK WARNINGS:

clang-tidy-report.txt:3:101: error: syntax error [syntaxError]
error: unable to handle compilation, expected exactly one compiler job in '' [clang-diagnostic-error]
                                                                                                    ^

Matlab example in README

pending resolution of pybind/pybind11#3945

Worth adding a note about gcc libs shipped with Matlab, like:

Note that since Matlab ships with and prioritizes its own GCC libraries (libgfortran.so,
libstdc++.so, libgcc_s.so, libquadmath.so), it is essential to build PyPartMC
with the [same version of GCC as the one Matlab files are based on](https://www.mathworks.com/matlabcen

ppmc = py.importlib.import_module('PyPartMC');
ver = char(py.getattr(ppmc, "__version__"))
system(['ldd ' char(py.getattr(ppmc, "__file__"))]) 
%GasState = ppmc.GasState;
%gas_state = GasState();
% ... TODO ()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.