Skip to content

Commit

Permalink
code rfactored
Browse files Browse the repository at this point in the history
  • Loading branch information
dhanush committed Mar 14, 2023
1 parent d7c6fa7 commit 00b817f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion HyAn/hyan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from PySide6.QtWidgets import QApplication
from HyAn.widgets.main_window import MainWindow


def main():
app = QApplication(sys.argv)
widget = MainWindow()
widget.show()
sys.exit(app.exec())

20 changes: 13 additions & 7 deletions HyAn/solution/theis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import math
from scipy.optimize import curve_fit

class Theis:

class Theis:
def __init__(self, time, drawdown, Q, r):
self.T = 0.0
self.S = 0.0
Expand All @@ -28,15 +28,15 @@ def calculate_well_function(self, r, S, T, t):
Returns:
- float or numpy array, value(s) of the well function at the specified time(s)
"""
u = (r ** 2) * S / (4 * T * t)
u = (r**2) * S / (4 * T * t)
Wu = -0.5772 - np.log(u) + u
n_terms = 30
for i in range(2, n_terms + 1):
sign = (-1) ** (i - 1)
factorial = np.math.factorial(i)
Wu += sign * (u ** i) / (i * factorial)
Wu += sign * (u**i) / (i * factorial)
return Wu

def calculate_drawdown(self, t, T, S):
"""
Calculates the drawdown at different times using the Theis equation.
Expand All @@ -58,10 +58,16 @@ def calculate_drawdown(self, t, T, S):
Wu_val = self.calculate_well_function(self.r, S, T, t[i])
drawdown[i] = self.Q * Wu_val / (4 * pi * T)
return drawdown

def fit(self):
popt, pcov = curve_fit(self.calculate_drawdown, self.time, self.drawdown, p0=self.initial_guess, bounds=self.bounds)
popt, pcov = curve_fit(
self.calculate_drawdown,
self.time,
self.drawdown,
p0=self.initial_guess,
bounds=self.bounds,
)
self.T = popt[0]
self.S = popt[1]
self.model = self.calculate_drawdown(self.time, self.T, self.S)
return [self.T, self.S, self.model]
return [self.T, self.S, self.model]
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from HyAn.hyan import main

if __name__ == "__main__":
main()
main()
28 changes: 15 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
import os
from setuptools import setup, find_packages


def read(rel_path: str) -> str:
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, rel_path)) as fp:
return fp.read()


def get_version(rel_path: str) -> str:
for line in read(rel_path).splitlines():
if line.startswith('__version__'):
if line.startswith("__version__"):
quote_char = '"' if '"' in line else "'"
return line.split(quote_char)[1]
raise RuntimeError("Unable to find version string.")


setup(
name='HyAn',
version=get_version("HyAn/__init__.py"),
packages=find_packages(),
install_requires=[
"matplotlib==3.7.1",
"numpy==1.24.2",
"PySide6==6.4.2",
"scipy==1.10.1",
"setuptools==65.6.3",
],
package_dir={'hydro-analyzer': 'HyAn'}
name="HyAn",
version=get_version("HyAn/__init__.py"),
packages=find_packages(),
install_requires=[
"matplotlib==3.7.1",
"numpy==1.24.2",
"PySide6==6.4.2",
"scipy==1.10.1",
"setuptools==65.6.3",
],
package_dir={"hydro-analyzer": "HyAn"},
)

0 comments on commit 00b817f

Please sign in to comment.