PLaSK library
Loading...
Searching...
No Matches
simple.py
Go to the documentation of this file.
1# This file is part of PLaSK (https://plask.app) by Photonics Group at TUL
2# Copyright (c) 2026 Lodz University of Technology
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, version 3.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12
13import unittest
14
15from numpy import *
16
17from plask import *
18from plask import material, geometry, mesh
19from electrical.capacitance import Capacitance2D
20
21from plask.phys import eps0 # 8.854187817e-6 pF/µm
22
23
24@material.simple()
26
27 def cond(self, T):
28 return 100.
29
30 def eps(self, T):
31 return 9.
32
33
35
36 def conductivity(self, mesh, interp=None):
37 matfield = MaterialField(self.solver.geometry, mesh)
38 return matfield.cond(300)
39
40
42
43 def setUp(self):
44 layer = geometry.Rectangle(1000., 100., Capacitor())
45 layer.role = 'active'
46 self.solver = Capacitance2D("capacitance2d")
47 self.solver.geometry = geometry.Cartesian2D(layer, length=1000.)
49 generator.prediv = 1, 10
50 self.solver.mesh = generator
53 self.solver.frequency = 1e3
54 self.solver.inDifferentialConductivity = flow.ConductivityProvider2D(self.conductivity)
55
56 def testCurrent(self):
57 self.solver.compute()
58 U = self.solver.outAcVoltage(self.solver.mesh)
59 correct_current = 1000. # mA
60 correct_imag_current = 2 * pi * self.solver.frequency * 9. * eps0 * 1000.**2 / 100. # mA
61 I = self.solver.get_ac_current()
62 self.assertAlmostEqual(I.real, correct_current, 6)
63 self.assertAlmostEqual(I.imag, correct_imag_current, 6)
64 Iact = self.solver.get_ac_current(active=True)
65 self.assertAlmostEqual(Iact, correct_current, 6)
66
67
68if __name__ == '__main__':
69 test = unittest.main(exit=False)
70 show()