Skip to content

Variance Reduced Integrated Charge#17

Open
gyalla wants to merge 21 commits intomainfrom
variance_reduced_integrated_charge
Open

Variance Reduced Integrated Charge#17
gyalla wants to merge 21 commits intomainfrom
variance_reduced_integrated_charge

Conversation

@gyalla
Copy link
Collaborator

@gyalla gyalla commented Feb 27, 2026

No description provided.

}

double evaluateMaxwellian(const mfem::Vector& primitive_state, const mfem::Vector velocity,const Species& species,const int dim){
//TODO: Do we want a default value if sigma == 0?
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't be able to get T<=0 so you add an error here if you'd like. I think we'd probably fail further upstream.

Copy link
Collaborator Author

@gyalla gyalla Feb 27, 2026

Choose a reason for hiding this comment

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

If error out when sigma<=0, several of our existing tests fail that use zero temperature. We can add a warning or perhaps return a NaN or negative probability

@gyalla gyalla force-pushed the variance_reduced_integrated_charge branch from 1eda0c6 to 3b4cac6 Compare February 27, 2026 22:32
@gyalla gyalla force-pushed the variance_reduced_integrated_charge branch from 5ea3a74 to 36d28cf Compare March 19, 2026 15:24
return out;
}

TEST(ParticleOperations, ErrorBetweenLowFidelityChargeAndPICChargeReducesWithParticleCountForMaxwellian) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@reuterb Take a look at this unit test and the following

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is checking that the PIC charge and the Euler charge match as N_part -> \infty? I think the test name is maybe a bit confusing in that regard. You could make this more rigorous by comparing to the expected value, using the expected error (related to the variance) as the tolerance for PIC.

}


TEST(ParticleOperations, ErrorBetweenVarianceReducedChargeAndPICChargeReducesWithParticleCountForMaxwellian) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

same thing here. I think we could be more direct.

We know the VR operation is unbiased so we'd expected a value of $E[\phi]$ with a tolerance related to the error $\sqrt{Var[\phi(1-f/f)]/N}$.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I may not be fully grasping what we're trying to do here though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This unit test and the last are simply checking that the error between the variance-reduced/low-fidelity charge and the standard PIC charge reduces with particle count. I wanted to make sure my variance reduced charge implementation was still converging towards the same value as the original PIC implementation.

I was holding off on computing variance and expectation of the estimator in a unit test since that would require multiple trials and that started to feel more like a regression test.

Copy link
Collaborator Author

@gyalla gyalla Mar 19, 2026

Choose a reason for hiding this comment

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

For a Maxwellian, the (1-fNR/f) factor is identical to 0, so the variance reduced charge is equal to the low fidelity charge. So this is just testing convergence of the PIC charge to the low-fidelity charge. If I use a kappa in the second unit test, that may be more meaningful.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This unit test and the last are simply checking that the error between the variance-reduced/low-fidelity charge and the standard PIC charge reduces with particle count. I wanted to make sure my variance reduced charge implementation was still converging towards the same value as the original PIC implementation.

I was holding off on computing variance and expectation of the estimator in a unit test since that would require multiple trials and that started to feel more like a regression test.

Isn't the variance reduced implementation exact in this case then? So basically these are just checking that the standard PIC charge converges?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the variance reduced implementation is exact, that's right. That is actually the first unit test I have in the file. If we use a kappa-distribution of particles and check that the variance-reduced charge and PIC charge still converge to the same answer, that seems like a good unit test for the new code.

@gyalla gyalla force-pushed the variance_reduced_integrated_charge branch from 3659a39 to 8f16690 Compare March 25, 2026 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants