Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle Manipulators: Init Multi Ion Species #1018

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Aug 6, 2015

This commit adds new manipulators that can be used during the species init-pipeline.

  • RatioWeightingImpl: Useful to clone one ion species from an other ion species by still satisfying the densityRatio of the new created species.
  • ProtonTimesWeightingImpl: Useful to clone electron species from an ion species for pre-ionized plasmas. The weighting of the electrons is simply multiplied by the proton number of the initial ion species.

Example Usage

in particleConfig.param:

namespace picongpu
{
namespace particles
{
// [...]
namespace manipulators
{
    // [...]
    typedef ProtonTimesWeightingImpl ProtonTimesWeighting;
    typedef RatioWeightingImpl RatioWeighting;
} /* namespace manipulators */
// [...]
} /* namespace particles */
} /* namespace picongpu */

in speciesInitialization.param:

namespace picongpu
{
namespace particles
{
    // [...]
    // Init-Pipeline for PMMA with Carbon, Oxygen, Proton and a general Electron species
    // (4 species in total, need to be defined in `speciesDefinition.param`)
    typedef mpl::vector<
        /* at this point, the reference density * densityRatio is taken to
         * calculate weightings */
        CreateGas<gasProfiles::SphereFlanks, startPosition::Random, PIC_Proton>,
        /* clone and weight additional ions according to their `densityRatio` */
        ManipulateCloneSpecies<manipulators::RatioWeighting, PIC_Proton, PIC_Carbon>,
        ManipulateCloneSpecies<manipulators::RatioWeighting, PIC_Proton, PIC_Oxygen>,
        /* re-distribute new ion species in their cell */
        Manipulate<manipulators::RandomPosition, PIC_Carbon>,
        Manipulate<manipulators::RandomPosition, PIC_Oxygen>,
        /* create electrons with numberOfProtons-higher weighting to emulate pre-ionization,
         * additionally, the initial plasma distribution is now field-neutral */
        ManipulateCloneSpecies<manipulators::ProtonTimesWeighting, PIC_Carbon, PIC_Electrons>,
        ManipulateCloneSpecies<manipulators::ProtonTimesWeighting, PIC_Oxygen, PIC_Electrons>,
        /* cloning from Hydrogen (Protons) is always easy: numberOfProtons == 1 */
        CloneSpecies<PIC_Proton, PIC_Electrons>
    > InitPipeline;
} /* namespace particles */
} /* namespace picongpu */

Alternatively, if CreateGas is using a quick/unexpensive functor and one does not care that MIN_WEIGHTING might create cells in low-density areas with only some of the three ion species:

namespace picongpu
{
namespace particles
{
    // [...]
    // Init-Pipeline for PMMA with Carbon, Oxygen, Proton and a general Electron species
    // (4 species in total, need to be defined in `speciesDefinition.param`)
    typedef mpl::vector<
        /* at this point, the reference density * densityRatio is taken to
         * calculate weightings */
        CreateGas<gasProfiles::SphereFlanks, startPosition::Random, PIC_Proton>,
        CreateGas<gasProfiles::SphereFlanks, startPosition::Random, PIC_Carbon>,
        CreateGas<gasProfiles::SphereFlanks, startPosition::Random, PIC_Oxygen>,
        /* create electrons with numberOfProtons-higher weighting to emulate pre-ionization,
         * additionally, the initial plasma distribution is now field-neutral */
        ManipulateCloneSpecies<manipulators::ProtonTimesWeighting, PIC_Carbon, PIC_Electrons>,
        ManipulateCloneSpecies<manipulators::ProtonTimesWeighting, PIC_Oxygen, PIC_Electrons>,
        /* cloning from Hydrogen (Protons) is always easy: numberOfProtons == 1 */
        CloneSpecies<PIC_Proton, PIC_Electrons>
    > InitPipeline;
} /* namespace particles */
} /* namespace picongpu */

Note

I did only add the second part of the documentation for the new work-flow in speciesInitialization.param (docs init pipeline) yet.
Missing part: the particleConfig.param (will probably be renamed) does include and select (via typedef) the particles/manipulators/ that are used in speciesInitialization.param and is not yet documented (will contain a list + short description of all manipulators before the next release, see #1020).

To do

  • compile test: I changed the namings a bit for the functors from my local branch (which was runtime tested)
  • add example in follow-up PR? (which one?)
  • add according .def file to each manipulator's .hpp file -> follow-up PR?

@ax3l ax3l added feature component: core in PIConGPU (core application) labels Aug 6, 2015
@ax3l ax3l added this to the Open Beta milestone Aug 6, 2015
@n01r
Copy link
Member

n01r commented Aug 6, 2015

Great job! ✨

Will you also add a Wiki entry for this subject?

@ax3l
Copy link
Member Author

ax3l commented Aug 6, 2015

thanks! :)
yes as linked: #1020 and #12

@PrometheusPi PrometheusPi self-assigned this Aug 7, 2015
@PrometheusPi
Copy link
Member

👍 great. I will have a look if you say its ready.

@PrometheusPi
Copy link
Member

@ax3l What is the current status of this pull request?

@ax3l
Copy link
Member Author

ax3l commented Aug 14, 2015

as written in the PR description and still without a tick: I did not do a run or compile time test for this PR, but the only thing I changed from my local branch are some namings.

@n01r
Copy link
Member

n01r commented Sep 15, 2015

Btw, I just noticed that the title of the PR seems a bit misleading:
I'd either call it Init Multi-Species or Init Multiple Ion Species
(or Init Multi-Electron Species if you were referring to initializing sth different than Hydrogen, which you are not even though you do 😉 ).

@ax3l ax3l changed the title Particle Manipulators: Init Multi-Ion Species Particle Manipulators: Init Multi Ion Species Sep 15, 2015
@ax3l
Copy link
Member Author

ax3l commented Nov 24, 2015

pls merge me

@ax3l ax3l force-pushed the topic-newMultiIonManipulators branch from 2db958b to 79fbfd2 Compare November 24, 2015 17:30
@PrometheusPi PrometheusPi self-assigned this Nov 26, 2015
@PrometheusPi
Copy link
Member

@ax3l I will review this pull request. But since you unassigned me 3 month ago: are you OK with that?

@ax3l
Copy link
Member Author

ax3l commented Nov 26, 2015 via email


/* Re-scale the weighting of a cloned species by numberOfProtons
*
* When cloning species from each other, the new
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, you are speaking about a general species but this manipulator is only useful for electrons. Could you specify species by saying electron species here (as in the description of the pull request) in order to clarify the comment?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I will describe it as an example use case that this is useful for electrons.

@PrometheusPi
Copy link
Member

@ax3l If I understand your RatioWeightingImpl correctly, you assume that densityRatio is normalized to your first ion species. Thus your density in the end is

total_density = density_species_1 + density_species_2
              =  density_species_1 * (1 + densityRatio) 
              >= density_species_1

Is this, what you intended? Or did you wanted to use a densityRatio à la:

total_density = density_species_X *  densityRatio_1 + density_species_X * densityRatio_2

@PrometheusPi
Copy link
Member

Great pull request 👍
Just some minor comments on names and one question on the definition of densityRatio.

@ax3l have you decided what you will do with the following points:

  • add example in follow-up PR? (which one?)
  • add according .def file to each manipulator's .hpp file -> follow-up PR?

@ax3l
Copy link
Member Author

ax3l commented Dec 3, 2015

I tried to write an actual example/ but it's too complex in the existing ones and I was a bit reluctant introducing yet-an-other example. but if we do, then in a follow-up.

I think all manipulators have a .def file now.

@ax3l
Copy link
Member Author

ax3l commented Dec 3, 2015

I need a some more days to finish the changes and to answer your last question, thx for the review already!

This commit adds new manipulators that can be used during the
species init-pipeline.

- `RatioWeightingImpl`: Useful to clone one ion species from an other
                        ion species by still satisfying the densityRatio
                        of the new created species.

- `ProtonTimesWeightingImpl`: Useful to clone electron species from
                              an ion species for pre-ionized plasmas.
                              The weighting of the electrons is simply
                              multiplied by the proton number of the
                              initial ion species.
@ax3l
Copy link
Member Author

ax3l commented Dec 8, 2015

If I understand your RatioWeightingImpl correctly, you assume that densityRatio is normalized to your first ion species. Thus your density in the end is ...

I don't normalize to something like a "total density" since such a quantity is not known to PIConGPU.

The only thing known is a reference density defined in gasConfig.param and a flag densityRatio (see speciesAttributes.param)

/*! alias for particle density ratio
 *
 * density ratio between default density @see `gasConfig.param` SI::GAS_DENSITY_SI
 * and a user defined species
 *
 * densityRatio is an *optional* flag of a species
 */
alias(densityRatio);

If a species defines a densityRatio it means: "if I am created from a gas profile, please create a weighting according to a normalized value of my densityRatio times SI::GAS_DENSITY_SI."
(fallback: densityRatio == 1.0)

Here is an example for PMMA / pmma, having 5*6 (C) + 2*8 (O) + 8*1 (H) = 54 electrons.

speciesDefinition.param:

// [...]
/* ratio relative to GAS_DENSITY for this species */
// electron density ratio is the same as fallback,
//   we just like to define reference densities in electron densities
value_identifier(float_X, DensityRatioElectrons, 1.0);
// ions
value_identifier(float_X, DensityRatioCarbon, 5./54.);
value_identifier(float_X, DensityRatioOxygen, 2./54.);
value_identifier(float_X, DensityRatioProton, 8./54.);

typedef bmpl::vector<
    // [...]
    densityRatio<DensityRatioOxygen>
> ParticleFlagsOxygen;

// [...]

Now the situation occurs that one wants to initialize a 2 (or more) ion species. One can now initialize both ions from a gas profile (CreateGas; honours the densityRatio * GAS_DENSITY for weightings) or one clones the second ion species from the first one (ManipulateCloneSpecies; can be beneficial, e.g., for computationally expensive/memory costly gas profiles).

While cloning one keeps the number of macro particles per cell constant for both species. To get the new species' weighting, simply calculate back to SI::GAS_DENSITY_SI by dividing by it's densityRatioSrc and then scale up to the new, cloned densityRatioDes:

            particleDesSpecies[weighting_] *= densityRatioDes / densityRatioSrc;

@PrometheusPi
Copy link
Member

@ax3l Thank you for introducing your intended workflow. The fact that you can initialize based on a gas profile and densityRatio made clear, why you could "normalize" to a SrcParticle.

I missed this line of code, that explained the rescaling to GAS_DENSITY if you initialized with a gas profile and densityRatio before.

@ax3l ax3l force-pushed the topic-newMultiIonManipulators branch from ef47335 to aae709a Compare December 8, 2015 16:34
@PrometheusPi
Copy link
Member

@ax3l Please update the license header of:

  • src/picongpu/include/particles/manipulators/DriftImpl.hpp
  • src/picongpu/include/particles/manipulators/FreeImpl.hpp
  • src/picongpu/include/particles/manipulators/SetAttributeImpl.hpp


/* Adjust the weighting of particleDes by densityRatio of own & Src particle
*
* While cloning a particle (particleDes) from an other (T_SrcParticle), one
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: an other -> another
see here

@ax3l
Copy link
Member Author

ax3l commented Dec 9, 2015

thx!

... and remove unused parameters.
@ax3l ax3l force-pushed the topic-newMultiIonManipulators branch from aae709a to 57cb32a Compare December 9, 2015 10:29
PrometheusPi added a commit that referenced this pull request Dec 9, 2015
Particle Manipulators: Init Multi Ion Species
@PrometheusPi PrometheusPi merged commit 499fc51 into ComputationalRadiationPhysics:dev Dec 9, 2015
@ax3l ax3l deleted the topic-newMultiIonManipulators branch December 9, 2015 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core in PIConGPU (core application)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants