-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathsin_cos.py
89 lines (66 loc) · 2.23 KB
/
sin_cos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Example file for the poisson problem
# Path: examples/poisson.py
# file contains the exact solution, rhs and boundary conditions for the poisson problem
import numpy as np
import tensorflow as tf
def left_boundary(x, y):
"""
This function will return the boundary value for given component of a boundary
"""
val = 0.0
return np.ones_like(x) * val
def right_boundary(x, y):
"""
This function will return the boundary value for given component of a boundary
"""
val = 0.0
return np.ones_like(x) * val
def top_boundary(x, y):
"""
This function will return the boundary value for given component of a boundary
"""
val = 0.0
return np.ones_like(x) * val
def bottom_boundary(x, y):
"""
This function will return the boundary value for given component of a boundary
"""
val = 0.0
return np.ones_like(x) * val
def rhs(x, y):
"""
This function will return the value of the rhs at a given point
"""
# f_temp = 32 * (x * (1 - x) + y * (1 - y))
# f_temp = 1
# For a Laplace Equation, Make the f_temp = np.ones_like(x) * 0.0
omegaX = 4.0 * np.pi
omegaY = 4.0 * np.pi
f_temp = -2.0 * (omegaX**2) * (np.sin(omegaX * x) * np.sin(omegaY * y))
return f_temp
def exact_solution(x, y):
"""
This function will return the exact solution at a given point
"""
# If the exact Solution does not have an analytical expression, leave the value as 0(zero)
# it can be set using `np.ones_like(x) * 0.0` and then ignore the errors and the error plots generated.
omegaX = 4.0 * np.pi
omegaY = 4.0 * np.pi
val = -1.0 * np.sin(omegaX * x) * np.sin(omegaY * y)
return val
def get_boundary_function_dict():
"""
This function will return a dictionary of boundary functions
"""
return {1000: bottom_boundary, 1001: right_boundary, 1002: top_boundary, 1003: left_boundary}
def get_bound_cond_dict():
"""
This function will return a dictionary of boundary conditions
"""
return {1000: "dirichlet", 1001: "dirichlet", 1002: "dirichlet", 1003: "dirichlet"}
def get_bilinear_params_dict():
"""
This function will return a dictionary of bilinear parameters
"""
eps = 1.0
return {"eps": eps}