• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mbakker7 / ttim / 12312733157

13 Dec 2024 09:08AM UTC coverage: 77.784% (+2.4%) from 75.342%
12312733157

Pull #81

github

web-flow
Merge fcd788ee4 into f9283bd02
Pull Request #81: Add cross-section models

503 of 632 new or added lines in 12 files covered. (79.59%)

42 existing lines in 3 files now uncovered.

3011 of 3871 relevant lines covered (77.78%)

2.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.19
/ttim/linedoublet1d.py
1
import matplotlib.pyplot as plt
3✔
2
import numpy as np
3✔
3

4
from ttim.element import Element
3✔
5
from ttim.equation import LeakyWallEquation
3✔
6

7

8
class LineDoublet1DBase(Element):
3✔
9
    """LineDoublet1D Base Class.
10

11
    All LineDoublet1D elements are derived from this class
12
    """
13

14
    tiny = 1e-8
3✔
15

16
    def __init__(
3✔
17
        self,
18
        model,
19
        xld=0,
20
        tsandbc=[(0, 0)],
21
        res="imp",
22
        layers=0,
23
        type="",
24
        name="LineDoublet1DBase",
25
        label=None,
26
    ):
27
        Element.__init__(
3✔
28
            self,
29
            model,
30
            nparam=1,
31
            nunknowns=0,
32
            layers=layers,
33
            tsandbc=tsandbc,
34
            type=type,
35
            name=name,
36
            label=label,
37
        )
38
        # Defined here and not in Element as other elements can have multiple
39
        # parameters per layers
40
        self.nparam = len(self.layers)
3✔
41
        self.xld = float(xld)
3✔
42
        if res == "imp":
3✔
NEW
43
            self.res = np.inf
×
44
        else:
45
            self.res = float(res)
3✔
46
        self.model.addelement(self)
3✔
47

48
    def __repr__(self):
3✔
NEW
49
        return self.name + " at " + str(self.xld)
×
50

51
    def initialize(self):
3✔
52
        # control point just on the positive side
53
        self.xc = np.array([self.xld + self.tiny])
3✔
54
        self.yc = np.zeros(1)
3✔
55
        # control point on the negative side
56
        self.xcneg = np.array([self.xld - self.tiny])
3✔
57
        self.ycneg = np.zeros(1)
3✔
58
        self.cosout = -np.ones(1)
3✔
59
        self.sinout = np.zeros(1)
3✔
60

61
        self.ncp = 1
3✔
62
        self.aq = self.model.aq.find_aquifer_data(self.xc[0], self.yc[0])
3✔
63
        self.setbc()
3✔
64
        coef = self.aq.coef[self.layers, :]
3✔
65
        self.setflowcoef()
3✔
66
        # term is shape (self.nparam,self.aq.naq,self.model.npval)
67
        self.term = self.flowcoef * coef
3✔
68
        self.term2 = self.term.reshape(
3✔
69
            self.nparam, self.aq.naq, self.model.nint, self.model.npint
70
        )
71
        self.dischargeinf = self.flowcoef * coef
3✔
72
        self.dischargeinflayers = np.sum(
3✔
73
            self.dischargeinf * self.aq.eigvec[self.layers, :, :], 1
74
        )
75
        self.resfac = self.aq.Haq[self.layers] / self.res
3✔
76

77
    def setflowcoef(self):
3✔
78
        """Separate function so that this can be overloaded for other types."""
79
        self.flowcoef = 1.0 / self.model.p  # Step function
3✔
80

81
    def potinf(self, x, _, aq=None):
3✔
82
        """Can be called with only one x value."""
83
        if aq is None:
3✔
NEW
84
            aq = self.model.aq.find_aquifer_data(x, 0.0)
×
85
        rv = np.zeros((self.nparam, aq.naq, self.model.npval), dtype=complex)
3✔
86
        if aq == self.aq:
3✔
87
            if (x - self.xld) < 0.0:
3✔
88
                pot = -0.5 * np.exp((x - self.xld) / aq.lab)
3✔
89
            elif (x - self.xld) >= 0.0:
3✔
90
                pot = 0.5 * np.exp(-(x - self.xld) / aq.lab)
3✔
91
            else:
NEW
92
                raise ValueError("Something wrong with passed x value.")
×
93
            rv[:] = self.term * pot
3✔
94
        return rv
3✔
95

96
    def disvecinf(self, x, y, aq=None):
3✔
97
        """Can be called with only one x,y value."""
98
        if aq is None:
3✔
NEW
99
            aq = self.model.aq.find_aquifer_data(x, y)
×
100
        rvx = np.zeros((self.nparam, aq.naq, self.model.npval), dtype=complex)
3✔
101
        rvy = np.zeros((self.nparam, aq.naq, self.model.npval), dtype=complex)
3✔
102
        if aq == self.aq:
3✔
103
            if (x - self.xld) < 0.0:
3✔
104
                qx = 0.5 * np.exp((x - self.xld) / aq.lab) / aq.lab
3✔
105
            elif (x - self.xld) >= 0.0:
3✔
106
                qx = 0.5 * np.exp(-(x - self.xld) / aq.lab) / aq.lab
3✔
107
            else:
NEW
108
                raise ValueError("Something wrong with passed x value.")
×
109
            rvx[:] = self.term * qx
3✔
110
        return rvx, rvy
3✔
111

112
    def changetrace(
3✔
113
        self, xyzt1, xyzt2, aq, layer, ltype, modellayer, direction, hstepmax
114
    ):
NEW
115
        raise NotImplementedError("changetrace not implemented for this element")
×
116

117
    def plot(self, ax=None):
3✔
118
        if ax is None:
3✔
NEW
119
            _, ax = plt.subplots()
×
120
        for ilay in self.layers:
3✔
121
            ax.plot(
3✔
122
                [self.xld, self.xld],
123
                [self.model.aq.zaqtop[ilay], self.model.aq.zaqbot[ilay]],
124
                "k-",
125
            )
126

127

128
class LeakyLineDoublet1D(LineDoublet1DBase, LeakyWallEquation):
3✔
129
    r"""Leaky line doublet with specified resistance.
130

131
    Parameters
132
    ----------
133
    model : Model object
134
        model to which the element is added
135
    xld : float
136
        x-coordinate of the line doublet
137
    res : float
138
        resistance of the line doublet
139
    layers : int, array or list
140
        layer (int) or layers (list or array) in which line doublet is located
141
    label : string or None (default: None)
142
        label of the element
143
    """
144

145
    def __init__(self, model, xld=0, res="imp", layers=0, label=None):
3✔
146
        super().__init__(
3✔
147
            model,
148
            xld,
149
            tsandbc=[(0, 0)],
150
            res=res,
151
            layers=layers,
152
            type="z",
153
            name="LeakyLineDoublet1D",
154
            label=label,
155
        )
156
        self.nunknowns = self.nparam
3✔
157

158
    def initialize(self):
3✔
159
        super().initialize()
3✔
160
        self.parameters = np.zeros(
3✔
161
            (self.model.ngvbc, self.nparam, self.model.npval), dtype=complex
162
        )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc