Skip to content
Snippets Groups Projects
Commit 139110de authored by abaucher's avatar abaucher
Browse files

Removed dynamo_

parent 9f1bb2c6
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -8,11 +8,7 @@ def convert_dynamo_file(filename, new_file):
nf.write(new_l)
def dy2pydy(l):
l = re.sub('^[ATRCLS] ', '', l)
l = re.sub('^N (\w*)', '\\1.i', l)
for b in {'len', 'all'}: # TODO: add other special names
l = re.sub(f'(?!<\w){b}((?!\w))', f'dynamo_{b}', l)
l = re.sub('^N (\w*)', '\\1.i', l)
l = re.sub('(?!<\w)smooth\((\w+?)\.k(?!\w)', 'smooth(\\1.j',l)
l = re.sub('\.kl', '.k', l)
l = re.sub('\.jk', '.j', l)
......
......@@ -77,6 +77,7 @@ def get_var_cst_fun(root):
list_params = list()
all_names = set()
all_vars = set()
all_nps_funs = set()
all_fun = dict()
for node in ast.walk(root):
if isinstance(node, ast.Name):
......@@ -91,8 +92,10 @@ def get_var_cst_fun(root):
'type': node.func.id,
'fun': node.func.id}
all_fun[node.func.id] = arg_fun
return {'cst': {c for c in all_names.difference(v for v, i in all_vars).difference(all_fun)
if c not in not_parse_fun},
else:
all_nps_funs.add(node.func.id)
return {'cst': {c for c in all_names.difference(v for v, i in all_vars).difference(all_fun).difference(all_nps_funs)
if c not in math_fun},
'var': all_vars,
'fun': all_fun}
......
......@@ -51,11 +51,11 @@ def get_nodes_eqs_dicts(lines):
all_nodes['var'].add(node)
# Add needed nodes
for node_type, arg_nodes in args['args'].items():
for arg_node in arg_nodes:
# Check if it's not a builtin fun
if node_type =='fun' and arg_node not in __builtins__:
all_nodes[node_type].add(arg_node)
for arg_node in args['args']['fun']:
if arg_node not in __builtins__:
all_nodes['fun'].add(arg_node)
if root.body and not type_found:
......
......@@ -38,15 +38,15 @@ def show_pyvis(s, init_val=True, notebook=False, options=None, highlight=None, c
Gq = Network(notebook=notebook, directed=True)
for a in G.nodes:
com = s.get_comment(a).split('\n')[0]
node = a.replace('dynamo_', '')
title = f"{com}<br>= {s.get_eq(a)}".replace('dynamo_', '')
node = a
title = f"{com}<br>= {s.get_eq(a)}"
col = colors[a] if colors and a in colors else None
# if init_val == True and a in dir(s):
# title = f'{title}<br>Init: {getattr(s, a)[0]:.2f}'
Gq.add_node(node, title=title, color=col)
for a, b in G.edges:
nodea, nodeb = (a.replace('dynamo_', ''), b.replace('dynamo_', ''))
nodea, nodeb = (a, b)
Gq.add_edge(nodea, nodeb)
if options:
Gq.show_buttons(options)
......
......@@ -31,8 +31,8 @@ m4t = [0.13, 0.11, 0.09, 0.07, 0.06, 0.05, 0.04]
# Death rate subsector
d.k = d1.j + d2.j + d3.j + d4.j
cdr.k = 1000*d.k/pop.k # death rate
le.k = dynamo_len*lmf.k*lmhs.k*lmp.k*lmc.k
dynamo_len = 28
le.k = len*lmf.k*lmhs.k*lmp.k*lmc.k
len = 28
lmf.k = tabhl(lmft, fpc.k/sfpc, 0, 5, 1)
lmft = [0, 1, 1.43, 1.5, 1.5, 1.5]
hsapc.k = tabhl(hsapct, sopc.k, 0, 2000, 250)
......@@ -93,7 +93,7 @@ fsafct = [0, 0.005, 0.015, 0.025, 0.03, 0.035]
# Capital sector
## Industrial subsector
iopc.k = io.k/pop.k
# ATTENTION: from next line a smdynamo_all difference is induced
# ATTENTION: from next line a small difference is induced
io.k = ic.k*(1-fcaor.k)*cuf.k/icor.k
icor.k = clip(icor2.k, icor1, time.k, pyear)
icor1 = 3
......@@ -236,14 +236,14 @@ mlymc.k = tabhl(mlymct, aiph.k, 0, 600, 40)
mlymct = [0.075, 0.03, 0.015, 0.011, 0.009, 0.008, 0.007, 0.006, 0.005, 0.005, 0.005, 0.005, 0.005, 0.005, 0.005, 0.005]
## Loop 3: land erosion and urban-industrial use
dynamo_all.k = alln*llmy.k
all.k = alln*llmy.k
alln = 1000
llmy.k = clip(0.95**((time.k - llmytm)/oy)*llmy1.k + (1 - 0.95**((time.k - llmytm)/oy))*llmy2.k, llmy1.k, time.k, llmytm)
llmy1.k = tabhl(llmy1t, ly.k/ilf, 0, 9, 1)
llmy1t = [1.2, 1, 0.63, 0.36, 0.16, 0.055, 0.04, 0.025, 0.015, 0.01]
llmy2.k = tabhl(llmy2t, ly.k/ilf, 0, 9, 1)
llmy2t = [1.2, 1, 0.63, 0.36, 0.29, 0.26, 0.24, 0.22, 0.21, 0.2] # WRLD3+03 !
ler.k = al.k/dynamo_all.k
ler.k = al.k/all.k
uilpc.k = tabhl(uilpct, iopc.k, 0, 1600, 200)
uilpct = [0.005, 0.008, 0.015, 0.025, 0.04, 0.055, 0.07, 0.08, 0.09]
uilr.k = uilpc.k*pop.k
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment