Skip to content

Commit

Permalink
0.3.1
Browse files Browse the repository at this point in the history
Fixed bug in delays functionality.
  • Loading branch information
JamesPHoughton committed Jun 18, 2015
1 parent 5ad0557 commit 5391738
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pysd/builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def add_flaux(filename, identifier, expression):
with open(filename, 'a') as outfile:
outfile.write(funcstr)

return 'self.%s()'%identifier


def add_to_element_docstring(component_class, identifier, string):
Expand Down Expand Up @@ -228,11 +229,11 @@ def add_n_delay(filename, input, delay_time, initial_value, order):
flowlist.append(add_flaux(filename,
identifier='%s_flow_%i_of_%i'%(delay_name, i, order+1),
expression='self.%s_stock_%i_of_%i()/(1.*%s/%i)'%(
delay_name, i, order+1, delay_time, order)))
delay_name, i-1, order, delay_time, order)))

for i in range(1, order+1):
add_stock(filename,
identifier='%s_stock_%i_of_%i'%(delay_name, i, order+1),
identifier='%s_stock_%i_of_%i'%(delay_name, i, order),
expression=flowlist[i-1]+' - '+flowlist[i],
initial_condition='%s * (%s / %i)'%(initial_value, delay_time, order))

Expand Down
6 changes: 3 additions & 3 deletions pysd/translators/vensim2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@ def visit_Unit(self, n, vc):
def visit_ConCall(self, n, (ConKeyword, _1, lparen, _2, args, _4, rparen)):
pass
if ConKeyword == 'DELAY1': #DELAY3(Inflow, Delay)
return builder.add_n_delay(self.component_class, args[0], args[1], str(0), 1)
return builder.add_n_delay(self.filename, args[0], args[1], str(0), 1)
elif ConKeyword == 'DELAY3':
return builder.add_n_delay(self.component_class, args[0], args[1], str(0), 3)
return builder.add_n_delay(self.filename, args[0], args[1], str(0), 3)
elif ConKeyword == 'DELAY N':#DELAY N(Inflow, Delay, init, order)
return builder.add_n_delay(self.component_class, args[0], args[1], args[2], args[3])
return builder.add_n_delay(self.filename, args[0], args[1], args[2], args[3])
elif ConKeyword == 'SMOOTH':
pass
elif ConKeyword == 'SMOOT3':
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
numpy
pandas
parsimonious
scipy

0 comments on commit 5391738

Please sign in to comment.