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

Numerical Integrator added to SRC along with the __init__() file #391

Merged
merged 10 commits into from
Jul 27, 2023

Conversation

Witt-D
Copy link
Collaborator

@Witt-D Witt-D commented Jul 24, 2023

Added a numerical integrator to Gusto SRC along with a corrosponding initialisation call into the innit() file

@Witt-D Witt-D changed the title added numerical integrator and libray call to __innit Numerical Integrator added to SRC along with the __init__() file Jul 24, 2023
class NumericalIntegral(object):
"""
A class for numerically evaluating and tabulating some 1D integral.
:arg lower_bound: lower bound of integral
Copy link
Contributor

Choose a reason for hiding this comment

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

These docstrings don't match the style now used through the rest of Gusto -- would you be able to be able to update this?

def evaluate_at(self, points):
"""
Evaluates the integral at some point using linear interpolation.
:arg points: the point value, or array of point values to evaluate
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with the docstrings here

def tabulate(self, expression):
"""
Tabulate some integral expression using Simpson's rule.
:arg expression: a function representing the integrand to be evaluated.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same with these docstrings

Copy link
Contributor

@tommbendall tommbendall left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! The main thing that we need is a unit-test for this, just to check some analytic integral

@Witt-D Witt-D requested a review from tommbendall July 25, 2023 15:27
Copy link
Contributor

@tommbendall tommbendall left a comment

Choose a reason for hiding this comment

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

Looking really good and it's very nearly ready to go on. Just a few tiny things left to sort. Thanks for doing this!

answer = 9
elif integrand_name == "sine":
integrand = sine
upperbound = 2*pi
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you integrate this to pi instead of 2*pi so that the answer isn't 0? Just in case the whole thing is doing nothing we would get 0 as the answer so this makes the test extra-safe

Evaluates the integral at some point using linear interpolation.
Args:
points (float or iter) the point value, or array of point values to
evaluate the integral at.
Copy link
Contributor

Choose a reason for hiding this comment

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

This docstring should also have a Returns: statement, as the function routines something

@@ -21,3 +21,4 @@
from gusto.timeloop import * # noqa
from gusto.transport_methods import * # noqa
from gusto.wrappers import * # noqa
from gusto.numerical_integrator import * # noqa
Copy link
Contributor

Choose a reason for hiding this comment

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

These imports are ordered alphabetically so could you put it in its correct place?

Copy link
Contributor

@tommbendall tommbendall left a comment

Choose a reason for hiding this comment

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

Looks great now, thanks for taking this on!

@tommbendall tommbendall merged commit 5beaa9e into main Jul 27, 2023
1 check passed
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