rb-daspk 0.0.2-x86-darwin-10 → 0.0.3-x86-darwin-10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rb-daspk.rb +41 -5
- data/lib/test.rb +2 -1
- metadata +8 -6
data/lib/rb-daspk.rb
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
#
|
25
25
|
# More information, source code and gems @ http://rubyforge.org/projects/rb-daspk/
|
26
26
|
#
|
27
|
-
|
27
|
+
#:include:test.rb
|
28
28
|
|
29
29
|
require 'rubygems'
|
30
30
|
require 'ffi'
|
@@ -57,6 +57,7 @@ module DASPK
|
|
57
57
|
callback :res, [:pointer,:pointer,:pointer,:pointer,:pointer,:pointer,:pointer,:pointer], :void
|
58
58
|
attach_function 'ddaspk_', [:res, :pointer,:pointer,:pointer,:pointer,:pointer,:pointer,:pointer,:pointer,:pointer,
|
59
59
|
:pointer,:pointer,:pointer,:pointer,:pointer,:pointer,:jac, :pointer], :void
|
60
|
+
attach_function 'd1mach_', [:pointer],:double
|
60
61
|
#
|
61
62
|
#
|
62
63
|
# interface to DASPK
|
@@ -73,7 +74,7 @@ module DASPK
|
|
73
74
|
|
74
75
|
include DASPK
|
75
76
|
|
76
|
-
attr_accessor :rtol,:atol,:init,:jac,:maxstep
|
77
|
+
attr_accessor :rtol,:atol,:init,:jac,:maxstep,:mxnit,:mxnj,:mxnh,:lsoff,:stptol,:epinit
|
77
78
|
#
|
78
79
|
#
|
79
80
|
# * neq = the number of equations. this is always the sum of the number of states and algebraics
|
@@ -102,8 +103,24 @@ module DASPK
|
|
102
103
|
@rtol = 0.000001
|
103
104
|
@atol = 0.000001
|
104
105
|
@jac = jac
|
105
|
-
|
106
|
-
|
106
|
+
|
107
|
+
|
108
|
+
@pmxnit = FFI::MemoryPointer.new(:int)
|
109
|
+
@pmxnj = FFI::MemoryPointer.new(:int)
|
110
|
+
@pmxnh = FFI::MemoryPointer.new(:int)
|
111
|
+
@plsoff = FFI::MemoryPointer.new(:int)
|
112
|
+
@pstptol = FFI::MemoryPointer.new(:double)
|
113
|
+
@pepinit = FFI::MemoryPointer.new(:double)
|
114
|
+
pidum = FFI::MemoryPointer.new(:int)
|
115
|
+
|
116
|
+
@maxstep = 0.0
|
117
|
+
@mxnit = 5
|
118
|
+
@mxnj = 6
|
119
|
+
@mxnh = 5
|
120
|
+
@lsoff = 0
|
121
|
+
@stptol = d1mach_(pidum)**(2.0/3.0)
|
122
|
+
@epinit = 0.01
|
123
|
+
@info[16] = 1
|
107
124
|
|
108
125
|
if (inter) then
|
109
126
|
@info[2]=1
|
@@ -172,7 +189,14 @@ module DASPK
|
|
172
189
|
# 0 means it is a state (aka has derivative in the equations)
|
173
190
|
# 1 means it is an algebraic
|
174
191
|
#
|
175
|
-
def solveForInitialValues(time,y,yprime,ialgs
|
192
|
+
def solveForInitialValues(time,y,yprime,ialgs,init=1)
|
193
|
+
|
194
|
+
@iwork[31] = @mxnit
|
195
|
+
@iwork[32] = @mxnj
|
196
|
+
@iwork[33] = @mxnh
|
197
|
+
@iwork[34] = @lsoff
|
198
|
+
@work[13] = @stptol
|
199
|
+
@work[14] = @epinit
|
176
200
|
|
177
201
|
ptime = FFI::MemoryPointer.new(:double)
|
178
202
|
ptime.write_double(time)
|
@@ -193,6 +217,7 @@ module DASPK
|
|
193
217
|
end
|
194
218
|
@info[13]=1
|
195
219
|
@piwork.write_array_of_int(@iwork)
|
220
|
+
@pwork.write_array_of_double(@work)
|
196
221
|
@pinfo.write_array_of_int(@info)
|
197
222
|
ddaspk_(@resproc,@pneq,ptime,@py,@pyprime,ptout,@pinfo,@prtol,@patol,pidid,@pwork,@plwr,@piwork,@plwi,nil,nil,@jacproc,nil)
|
198
223
|
@y.replace @py.read_array_of_double(@neq)
|
@@ -205,6 +230,7 @@ module DASPK
|
|
205
230
|
end
|
206
231
|
@info[13]=1
|
207
232
|
@piwork.write_array_of_int(@iwork)
|
233
|
+
@pwork.write_array_of_double(@work)
|
208
234
|
@pinfo.write_array_of_int(@info)
|
209
235
|
ddaspk_(@resproc,@pneq,ptime,@py,@pyprime,ptout,@pinfo,@prtol,@patol,pidid,@pwork,@plwr,@piwork,@plwi,nil,nil,@jacproc,nil)
|
210
236
|
@y.replace @py.read_array_of_double(@neq)
|
@@ -219,6 +245,16 @@ module DASPK
|
|
219
245
|
end
|
220
246
|
|
221
247
|
def solve (time, tout)
|
248
|
+
|
249
|
+
#
|
250
|
+
# solver options
|
251
|
+
#
|
252
|
+
@iwork[31] = @mxnit
|
253
|
+
@iwork[32] = @mxnj
|
254
|
+
@iwork[33] = @mxnh
|
255
|
+
@iwork[34] = @lsoff
|
256
|
+
@work[13] = @stptol
|
257
|
+
@work[14] = @epinit
|
222
258
|
|
223
259
|
@prtol.write_double(@rtol)
|
224
260
|
@patol.write_double(@atol)
|
data/lib/test.rb
CHANGED
@@ -24,7 +24,6 @@
|
|
24
24
|
#
|
25
25
|
# More information, source code and gems @ http://rubyforge.org/projects/rb-daspk/
|
26
26
|
#
|
27
|
-
#
|
28
27
|
|
29
28
|
require 'rubygems'
|
30
29
|
require 'rb-daspk'
|
@@ -129,3 +128,5 @@ ypa = ans[2]
|
|
129
128
|
ya = ans[1]
|
130
129
|
print "time = #{time} y0=#{ya[0]} y1=#{ya[1]}\n"
|
131
130
|
print "time = #{time} yp0=#{ypa[0]} yp1=#{ypa[1]}\n"
|
131
|
+
|
132
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-daspk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: x86-darwin-10
|
6
6
|
authors:
|
7
7
|
- Eric Meyers
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-29 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -34,8 +34,10 @@ files:
|
|
34
34
|
- lib/libdaspk.dylib
|
35
35
|
- lib/rb-daspk.rb
|
36
36
|
- lib/test.rb
|
37
|
-
has_rdoc:
|
38
|
-
homepage:
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://rb-daspk.rubyforge.org
|
39
|
+
licenses: []
|
40
|
+
|
39
41
|
post_install_message:
|
40
42
|
rdoc_options:
|
41
43
|
- --inline-source
|
@@ -56,9 +58,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
58
|
requirements: []
|
57
59
|
|
58
60
|
rubyforge_project: rb-daspk
|
59
|
-
rubygems_version: 1.3.
|
61
|
+
rubygems_version: 1.3.5
|
60
62
|
signing_key:
|
61
|
-
specification_version:
|
63
|
+
specification_version: 3
|
62
64
|
summary: DASPK Ruby Interface. Allows users to solve differential algebraic equations in Ruby, using Ruby constructs. Interfaces with the DASPK Fortran library. DASPK solves DAE's of the form G(t,y,y',p) = 0
|
63
65
|
test_files: []
|
64
66
|
|