-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.rd
158 lines (114 loc) · 5.44 KB
/
README.rd
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#---------------------------------------------------------------------------------
#
# ABOUT THE PROJECT
#
#---------------------------------------------------------------------------------
Implementation of Numerical Methods
Center for Informatics, Federal University of Pernambuco (CIn/UFPE)
@author: Ermano A. Arruda <eaa3@cin.ufpe.br>
Implemented methods:
----One-step/Stepwise/Starting Methods----
1) Euler (error ~ h^2)
2) Improved Euler Method (Modified Euler) (error ~ h^3)
3) Backward Euler Method (error ~ h^2)
4) Runge-Kutta Method (error ~ h^4)
5) Three Term Taylor Series Method (error ~ h^3)
----Multistep or Continuing Methods----
6) Adams-Bashforth[1,2,3,4] (error = h^2, h^3, h^4, h^5 - respectively )
7) Adams-Multon[1,2,3,4] (error = h^2, h^3, h^4, h^5 - respectively )
8) Preditor-Corrector[1,2,3,4] (error = h^2, h^3, h^4, h^5 - respectively )
9) Backward Differentiation (BackDiff[1,2,3,4]) (error = h^2, h^3, h^4, h^5 - respectively )
#---------------------------------------------------------------------------------
#
# DEPENDENCIES OF THE PROGRAM
#
#---------------------------------------------------------------------------------
The code needs numpy, matplotlib and sympy to run
Installing numpy:
1) pip install numpy
If you can check the general installation guide on http://www.numpy.org
Installing matplotlib:
1) matplotlib is a plotting library.
To install it you can simply follow the instructions on the official website:
http://matplotlib.org/users/installing.html
Installing Sympy:
1) To install sympy you can simply follow the instructions on the official website:
http://docs.sympy.org/latest/install.html
#---------------------------------------------------------------------------------
#
# HOW TO EXECUTE THE PROGRAM
#
#---------------------------------------------------------------------------------
You can execute the code using the following command on the shell:
1) python DSolver.py [OptionalInputFileName.txt]
If the [OptionalInputFileName.txt] is not provided, provided the default inputFile.txt will be used.
#---------------------------------------------------------------------------------
#
# THE INPUT FILE
#
#---------------------------------------------------------------------------------
The input file sets the first order linear diferential equation to be solved, as well as the numerical method to be used and its parameters.
It should have the format bellow (See also the default inputFile.txt already provided with the project source)
If for some reason you dont the inputFile.txt, create it and copy and paste the content below:
# \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#---------------------------------------------------------------------------------
# THE INPUT FILE FORMAT (default inputFile.txt)
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
# First order differential linear equation
# y' = g(x) - p(x)*y
#
# (!!) -> YOU MUST USE THE VARIABLES x and y (IN LOWERCASE),
# (!!) -> NO OTHER VARIABLE SYMBOL IS ALLOWED.
#---------------------------------------------------------------------------------
yd = "1-x + 4*y"
#---------------------------------------------------------------------------------
# Exact solution (if you dont have phi, make phi = None)
#---------------------------------------------------------------------------------
phi = (x/4) - (3/16) + exp(4*x)*(19/16)
#---------------------------------------------------------------------------------
# Initial value
#---------------------------------------------------------------------------------
y0 = 1
#---------------------------------------------------------------------------------
# Step size
#---------------------------------------------------------------------------------
h = 0.1
#---------------------------------------------------------------------------------
# Number of evaluations
#---------------------------------------------------------------------------------
n = 10
#---------------------------------------------------------------------------------
# Error Correction Threshold (only used for Predictor-Corrector method)
# typically 0 < episolon < 1, but episolon may be > 1
#---------------------------------------------------------------------------------
episolon = 0.3
#---------------------------------------------------------------------------------
# The method must be one of the following values:
#
# 1) "Euler"
#
# 2) "BackEuler"
#
# 3) "ImpEuler"
#
# 4) "RungeKutta"
#
# 5) "Taylor"
#
# 6) "Adams-Bashforth[X]" where [X] is one of the following values [1,2,3,4]
# (e.g. Adams-Bashforth1 is adams-bashforth method of degree one)
#
# 7) "Adams-Multon[X]" where [X] is one of the following values [1,2,3,4]
# (e.g. Adams-Multon1 is the adams-multon method of degree one)
#
# 8) "Predictor-Corrector[X]" where [X] is one of the following values [1,2,3,4]
# (e.g. Preditor-Corrector1 is the Preditor-Corrector method of degree one)
#
# 9) "BackDiff[X]" where [X] is one of the following values [1,2,3,4]
# (e.g. BackDiff1 is the Backward differentiation formula method of degree one)
#---------------------------------------------------------------------------------
Predictor-Corrector3
#---------------------------------------------------------------------------------
# END OF FILE
#---------------------------------------------------------------------------------