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

Vectorize call to integral of the error function (_erfint) #114

Closed
MassimoCimmino opened this issue May 21, 2021 · 1 comment · Fixed by #115
Closed

Vectorize call to integral of the error function (_erfint) #114

MassimoCimmino opened this issue May 21, 2021 · 1 comment · Fixed by #115
Assignees
Milestone

Comments

@MassimoCimmino
Copy link
Owner

In heat_transfer.finite_line_source, the integrand function includes a sum of integrals of the error function :

if reaSource and imgSource:
# Full (real + image) FLS solution
f = lambda s: 0.5 / (H2*s**2) * np.exp(-dis**2*s**2) * (
_erfint((D2 - D1 + H2)*s) - _erfint((D2 - D1)*s)
+ _erfint((D2 - D1 - H1)*s) - _erfint((D2 - D1 + H2 - H1)*s)
+ _erfint((D2 + D1 + H2)*s) - _erfint((D2 + D1)*s)
+ _erfint((D2 + D1 + H1)*s) - _erfint((D2 + D1 + H2 + H1)*s) )

The sum can be vectorized as follows :

    if reaSource and imgSource:
        # Full (real + image) FLS solution
        p = np.array([1, -1, 1, -1, 1, -1, 1, -1])
        q = np.stack([D2 - D1 + H2,
                      D2 - D1,
                      D2 - D1 - H1,
                      D2 - D1 + H2 - H1,
                      D2 + D1 + H2,
                      D2 + D1,
                      D2 + D1 + H1,
                      D2 + D1 + H2 + H1],
                     axis=-1)
        f = lambda s: 0.5 / (H2*s**2) * np.exp(-dis**2*s**2) * np.inner(p, _erfint(q*s))

This should be more efficient and save some calculation especially for smaller bore fields.

@MassimoCimmino
Copy link
Owner Author

Same test cases as in #78.


Case 1 : Rectangular fields up to 12 by 12

Figure_1-Rectangular-Time
Figure_1-Rectangular-Error


Case 2 : Number of segments for a 5 by 5 bore field

Figure_2-Segments-Time
Figure_2-Segments-Error


Case 3 : Field of 100 boreholes with 2 different lengths

Figure_3-Special-Field
Figure_3-Special-gFunc
Figure_3-Special-Error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant