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

fix bulk velocity for populations having different masses #782

Closed
nicolasaunai opened this issue Nov 21, 2023 · 1 comment
Closed

fix bulk velocity for populations having different masses #782

nicolasaunai opened this issue Nov 21, 2023 · 1 comment
Assignees
Labels
bug 🔥 Something isn't working
Milestone

Comments

@nicolasaunai
Copy link
Member

current code for the computation of the bulk velocity below:

            for (auto& pop : populations_)
            {
                auto& flux = pop.flux();
                auto& fx   = flux.getComponent(Component::X);
                auto& fy   = flux.getComponent(Component::Y);
                auto& fz   = flux.getComponent(Component::Z);

                std::transform(std::begin(vx), std::end(vx), std::begin(fx), std::begin(vx),
                               std::plus<typename field_type::type>{});
                std::transform(std::begin(vy), std::end(vy), std::begin(fy), std::begin(vy),
                               std::plus<typename field_type::type>{});
                std::transform(std::begin(vz), std::end(vz), std::begin(fz), std::begin(vz),
                               std::plus<typename field_type::type>{});
            }

            std::transform(std::begin(vx), std::end(vx), std::begin(*rho_), std::begin(vx),
                           std::divides<typename field_type::type>{});
            std::transform(std::begin(vy), std::end(vy), std::begin(*rho_), std::begin(vy),
                           std::divides<typename field_type::type>{});
            std::transform(std::begin(vz), std::end(vz), std::begin(*rho_), std::begin(vz),
                           std::divides<typename field_type::type>{});

does sum_pop(flux_pop)/sum_pop(rho_pop)

where rho_pop is just the particle density of the population pop.

This is wrong when populations have different masses.

It should be.:

sum_pop(mass_pop * flux_pop)/sum_pop(mass_pop*rho_pop)

@nicolasaunai nicolasaunai added the bug 🔥 Something isn't working label Nov 21, 2023
@nicolasaunai nicolasaunai added this to the 1.1 milestone Nov 21, 2023
@nicolasaunai nicolasaunai self-assigned this Nov 21, 2023
@nicolasaunai nicolasaunai moved this to In Progress 👀 in PHARE Roadmap Nov 23, 2023
@nicolasaunai nicolasaunai moved this from In Progress 👀 to Done 🥳 in PHARE Roadmap Dec 3, 2023
@nicolasaunai
Copy link
Member Author

closed , done by #783

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🔥 Something isn't working
Projects
Status: Done 🥳
Development

No branches or pull requests

1 participant