TransWikia.com

Integration of a discretized field in a cylindrical coordinate system

Computational Science Asked on June 7, 2021

I would like to integrate a discretized field in cylindrical coordinates, given as A(r, z), with z being spaced regularly (spacing distance dz), and r being spaced non-regularly. Moreover, r[0]>0 due to the chosen discretization. For integration, I would like to use the trapezoidal approach, and start with the z-component, to integrate everything into a vector aux:

for (int i = 0; i < Nr; ++i) {
    for (int j = 0; j < Nt; ++j) {
        double I = A(i, j);
        if ((j == 0) || (j == Nt - 1))
            I *= 0.5;
        aux(i) += I;
    }
    aux(i) *= dz;
}

For the integration along the r-axis I then have to consider the different spacing, resulting in

double integral = 0;
for (int i = Nr; i > 0; --i) {
    integral += (r(i) * aux(i) + r(i - 1) * aux(i - 1)) / 2
            * (r(i) - r(i-1));
}

Finally, after r[0] > 0 I also have to take that into account by adding

integral += 0.5 * aux(0) * r(0) * r(0);

and add the missing $2pi$:

integral *= 2 * M_PI;

Is that approach correct, or did I miss a factor here somewhere?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP