uncscode / particula

a simple, fast, and powerful particle simulator
https://uncscode.github.io/particula
MIT License
5 stars 9 forks source link

request for input #137

Closed ngam closed 2 years ago

ngam commented 2 years ago

Mainly from @aktwo and @wkchuang:

@Gorkowski and I have decided to push forward with the utilities to pursue the parcel stuff. I have done most of the coding, but I have intentionally left all object-oriented stuff untouched for now for two reasons. One: I didn't want to overwrite/edit anything before thorough consultation and discussion. Two: I am not really sure how best to do this anyway.

What have I done?

  1. Essentially, added a lot of small utilities with decent testing and documentation (not for all; some need more work).
  2. I have written very minimal code to use the utilities all the way up to calculating a coagulation rate. This involves:
    1. calculating utilities leading up to and including the coagulation kernel --- the coagulation "kernel" is simply a representation of coagulation coefficients, with units like length^3/time.
    2. introduce a number distribution following the traditional lognormal --- while easy to implement from scratch, I opted to use scipy's module; I will document this more because it is actually quite tricky in general especially vis-a-vis the interpretation of these distributions
    3. based on the distribution + kernel, I calculated the coagulation rates --- now we are talking about dynamics! Roughly speaking, a coagulation rate goes something like PARTICLE*PARTICLE*KERNEL, where a particle is represented by concentration (the distribution). So, (#/length^3)*(#/length^3)*(length^3/time) gives you #/time/length^3 or the change (1/time) of particles (#/length^3)
    4. added some basic testing for mass conservation. Note: to convert from number rate (#/time/length^3) to mass rate, it is sufficient to just convert to "pure" rate, assuming constant density, 1/time. This is achieved by integrating (e.g. numpy.trapz) with a surface area (this is related to the trickery and confusion behind how these probability density functions are defined --- I can explain more later)

What's next? I will need to get you up to speed with all these details because my implementation is 1) far from perfect and 2) we need to start implementing it this in the original framework/workflow (the particle class, etc.). In a way, my vision is such that the class structure can be used for organization rather than calculation. All calculations should be done in utilities and isolated int he /util/ folder. The reasons: 1) portability and generality of these calculations and 2) thorough testing for them.

The input:

wkchuang commented 2 years ago

Thanks @ngam and @Gorkowski for doing all the organization! I'll read through the details and history tonight, try to catch myself up with all the changes, and see what ideas and questions I have

ngam commented 2 years ago

@wkchuang, it is a long history and maybe badly explained history! 😆 So please don't waste too much time if you find yourself wondering what the hell is going on... and just let me know and I will do my best to document and explain.

An option is to start slowly integrating the utilities into the particle, environment and parcel classes. That way, you can see them in action. Another option, is that I can write a long notebook going through them and explaining how choices were made, etc. and highlighting areas that need improvement, etc.

aktwo commented 2 years ago

Sorry for the delayed response, was traveling for the last few days and have a bunch of things scheduled this week. I'll need a few days (and maybe even as late as the weekend after this one) to digest this (plus I think there's a lot of science here that I don't fully understand) so don't block on me unless you'd explicitly like my input on this.

And just double checking, are the changes you'd like reviewed in https://github.com/uncscode/particula/pull/136 or somewhere else?

ngam commented 2 years ago

@aktwo, no worries, please take your time. Actually, no feedback is needed on any of the current PRs as they merely deal with stuff that will likely remain behind the scene (/util/). The input I'd like is about how to integrate the utilities into the classes (e.g. Particle). For that, I will need to bring you up to speed with these util at some point, so maybe we can either do a notebook (cc @Gorkowski who's already written one) or we I can start proposing baby changes to the object-oriented stuff (Particle, Environment, etc.) so that we use the utilities in the classes...