Rimjhim Mittal commited on
Commit ·
73d192f
1
Parent(s): 8777e24
app working for FN.mdf.json and array inputs
Browse files- app.py +147 -61
- examples/ABCD.json +185 -0
- examples/Arrays.json +93 -0
- examples/FN.mdf.json +4 -0
- examples/IAFs.json +241 -0
- examples/NewtonCoolingModel.json +18 -2
- examples/RNNs.json +197 -0
- examples/{SwitchedRLC_Circuit.json → switched_rlc_circuit.json} +29 -14
app.py
CHANGED
|
@@ -3,6 +3,7 @@ from modeci_mdf.mdf import Model, Graph, Node, Parameter, OutputPort
|
|
| 3 |
from modeci_mdf.utils import load_mdf_json, load_mdf, load_mdf_yaml
|
| 4 |
from modeci_mdf.execution_engine import EvaluableGraph, EvaluableOutput
|
| 5 |
import json
|
|
|
|
| 6 |
import requests
|
| 7 |
st.set_page_config(layout="wide", page_icon="logo.png", page_title="Model Description Format", menu_items={
|
| 8 |
'Report a bug': "https://github.com/ModECI/MDF/",
|
|
@@ -10,43 +11,98 @@ st.set_page_config(layout="wide", page_icon="logo.png", page_title="Model Descri
|
|
| 10 |
})
|
| 11 |
|
| 12 |
# models: Purpose: To store the state of the model and update the model
|
|
|
|
|
|
|
| 13 |
def run_simulation(param_inputs, mdf_model):
|
| 14 |
mod_graph = mdf_model.graphs[0]
|
| 15 |
nodes = mod_graph.nodes
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
eg.evaluate()
|
| 31 |
-
else:
|
| 32 |
-
eg.evaluate(time_increment=dt)
|
| 33 |
-
|
| 34 |
-
for param in output_values:
|
| 35 |
-
if any(operator in param for operator in "+-/*"):
|
| 36 |
-
eval_param = eg.enodes[node.id].evaluable_outputs[param]
|
| 37 |
-
|
| 38 |
else:
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
chart_data = pd.DataFrame(output_values)
|
| 43 |
chart_data['Time'] = times
|
| 44 |
chart_data.set_index('Time', inplace=True)
|
|
|
|
| 45 |
show_simulation_results(chart_data)
|
| 46 |
return None
|
| 47 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
def show_simulation_results(chart_data):
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
def show_mdf_graph(mdf_model):
|
| 52 |
st.subheader("MDF Graph")
|
|
@@ -61,21 +117,32 @@ def show_json_output(mdf_model):
|
|
| 61 |
def view_tabs(mdf_model, param_inputs): # view
|
| 62 |
tab1, tab2, tab3 = st.tabs(["Simulation Results", "MDF Graph", "Json Output"])
|
| 63 |
with tab1:
|
| 64 |
-
# mod_graph = mdf_model.graphs[0]
|
| 65 |
-
# nodes = mod_graph.nodes
|
| 66 |
-
# for node in nodes:
|
| 67 |
-
# st.write("Node Name: ", node.id)
|
| 68 |
-
# node_parameters = {}
|
| 69 |
-
# for param in node.parameters:
|
| 70 |
-
# node_parameters[param.id] = node_parameters[param.id] = param.value if param.value else param.time_derivative
|
| 71 |
-
# st.write("Node Parameters: ", node_parameters)
|
| 72 |
run_simulation(param_inputs, mdf_model) # model
|
| 73 |
-
# show_simulation_results(chart_data) # view
|
| 74 |
with tab2:
|
| 75 |
show_mdf_graph(mdf_model) # view
|
| 76 |
with tab3:
|
| 77 |
show_json_output(mdf_model) # view
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
def parameter_form_to_update_model_and_view(mdf_model, parameters, param_inputs, mod_graph, nodes):
|
| 80 |
with st.form(key="parameter_form"):
|
| 81 |
valid_inputs = True
|
|
@@ -93,16 +160,21 @@ def parameter_form_to_update_model_and_view(mdf_model, parameters, param_inputs,
|
|
| 93 |
current_col = col1 if i % 2 == 0 else col2
|
| 94 |
|
| 95 |
with current_col:
|
| 96 |
-
if
|
| 97 |
-
|
|
|
|
| 98 |
else:
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
|
| 102 |
-
param_inputs[param.id] = float(value)
|
| 103 |
-
except ValueError:
|
| 104 |
-
st.error(f"Invalid input for {param.id}. Please enter a valid number.")
|
| 105 |
-
valid_inputs = False
|
| 106 |
st.write("Simulation Parameters:")
|
| 107 |
with st.container(border=True):
|
| 108 |
# Add Simulation Duration and Time Step inputs
|
|
@@ -203,27 +275,41 @@ def upload_file_and_load_to_model():
|
|
| 203 |
st.error(f"Error loading file from GitHub: {e}")
|
| 204 |
return None
|
| 205 |
# with col2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
example_models = {
|
| 207 |
-
"Newton Cooling Model": "
|
| 208 |
-
"ABCD": "
|
| 209 |
-
"FN": "
|
| 210 |
-
"States": "
|
| 211 |
-
"
|
|
|
|
|
|
|
|
|
|
| 212 |
}
|
| 213 |
selected_model = st.selectbox("Choose an example model", list(example_models.keys()), index=None)
|
| 214 |
if selected_model:
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
response = requests.get(example_url)
|
| 218 |
-
response.raise_for_status()
|
| 219 |
-
file_content = response.content
|
| 220 |
-
file_extension = example_url.split('.')[-1].lower()
|
| 221 |
-
return load_model_from_content(file_content, file_extension)
|
| 222 |
-
except requests.RequestException as e:
|
| 223 |
-
st.error(f"Error loading example model: {e}")
|
| 224 |
-
return None
|
| 225 |
-
# st.button("Newton Cooling Model", on_click=load_mdf_json(""))
|
| 226 |
-
return None
|
| 227 |
|
| 228 |
|
| 229 |
def load_model_from_content(file_content, file_extension):
|
|
|
|
| 3 |
from modeci_mdf.utils import load_mdf_json, load_mdf, load_mdf_yaml
|
| 4 |
from modeci_mdf.execution_engine import EvaluableGraph, EvaluableOutput
|
| 5 |
import json
|
| 6 |
+
import numpy as np
|
| 7 |
import requests
|
| 8 |
st.set_page_config(layout="wide", page_icon="logo.png", page_title="Model Description Format", menu_items={
|
| 9 |
'Report a bug': "https://github.com/ModECI/MDF/",
|
|
|
|
| 11 |
})
|
| 12 |
|
| 13 |
# models: Purpose: To store the state of the model and update the model
|
| 14 |
+
import numpy as np
|
| 15 |
+
|
| 16 |
def run_simulation(param_inputs, mdf_model):
|
| 17 |
mod_graph = mdf_model.graphs[0]
|
| 18 |
nodes = mod_graph.nodes
|
| 19 |
+
with st.spinner('Plotting the curve...'):
|
| 20 |
+
for node in nodes:
|
| 21 |
+
parameters = node.parameters
|
| 22 |
+
outputs = node.output_ports
|
| 23 |
+
eg = EvaluableGraph(mod_graph, verbose=False)
|
| 24 |
+
duration = param_inputs["Simulation Duration (s)"]
|
| 25 |
+
dt = param_inputs["Time Step (s)"]
|
| 26 |
+
t = 0
|
| 27 |
+
times = []
|
| 28 |
+
output_values = {op.value: [] for op in outputs}
|
| 29 |
+
while t <= duration:
|
| 30 |
+
times.append(t)
|
| 31 |
+
if t == 0:
|
| 32 |
+
eg.evaluate()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
else:
|
| 34 |
+
eg.evaluate(time_increment=dt)
|
| 35 |
+
|
| 36 |
+
for param in output_values:
|
| 37 |
+
if any(operator in param for operator in "+-/*"):
|
| 38 |
+
eval_param = eg.enodes[node.id].evaluable_outputs[param]
|
| 39 |
+
else:
|
| 40 |
+
eval_param = eg.enodes[node.id].evaluable_parameters[param]
|
| 41 |
+
output_value = eval_param.curr_value
|
| 42 |
+
if isinstance(output_value, (list, np.ndarray)):
|
| 43 |
+
# Extract the scalar value from the list or array
|
| 44 |
+
scalar_value = output_value[0] if len(output_value) > 0 else np.nan
|
| 45 |
+
output_values[param].append(float(scalar_value)) # Convert to Python float
|
| 46 |
+
else:
|
| 47 |
+
output_values[param].append(float(output_value)) # Convert to Python float
|
| 48 |
+
t += dt
|
| 49 |
+
|
| 50 |
chart_data = pd.DataFrame(output_values)
|
| 51 |
chart_data['Time'] = times
|
| 52 |
chart_data.set_index('Time', inplace=True)
|
| 53 |
+
print(chart_data)
|
| 54 |
show_simulation_results(chart_data)
|
| 55 |
return None
|
| 56 |
+
# def run_simulation(param_inputs, mdf_model):
|
| 57 |
+
# mod_graph = mdf_model.graphs[0]
|
| 58 |
+
# nodes = mod_graph.nodes
|
| 59 |
+
# for node in nodes:
|
| 60 |
+
# parameters = node.parameters
|
| 61 |
+
# outputs = node.output_ports
|
| 62 |
+
# eg = EvaluableGraph(mod_graph, verbose=False)
|
| 63 |
+
# duration = param_inputs["Simulation Duration (s)"]
|
| 64 |
+
# dt = param_inputs["Time Step (s)"]
|
| 65 |
+
# t = 0
|
| 66 |
+
# times = []
|
| 67 |
+
# output_values = {op.value: [] for op in outputs}
|
| 68 |
+
# while t <= duration:
|
| 69 |
+
# times.append(t)
|
| 70 |
+
# if t == 0:
|
| 71 |
+
# eg.evaluate()
|
| 72 |
+
# else:
|
| 73 |
+
# eg.evaluate(time_increment=dt)
|
| 74 |
+
|
| 75 |
+
# for param in output_values:
|
| 76 |
+
# if any(operator in param for operator in "+-/*"):
|
| 77 |
+
# eval_param = eg.enodes[node.id].evaluable_outputs[param]
|
| 78 |
+
# else:
|
| 79 |
+
# eval_param = eg.enodes[node.id].evaluable_parameters[param]
|
| 80 |
+
# output_value = eval_param.curr_value
|
| 81 |
+
# if isinstance(output_value, (list, np.ndarray)):
|
| 82 |
+
# # Extract the scalar value from the list or array
|
| 83 |
+
# output_values[param].append(output_value[0] if len(output_value) > 0 else np.nan)
|
| 84 |
+
# else:
|
| 85 |
+
# output_values[param].append(output_value)
|
| 86 |
+
# t += dt
|
| 87 |
+
|
| 88 |
+
# chart_data = pd.DataFrame(output_values)
|
| 89 |
+
# chart_data['Time'] = times
|
| 90 |
+
# chart_data.set_index('Time', inplace=True)
|
| 91 |
+
# print(chart_data)
|
| 92 |
+
# show_simulation_results(chart_data)
|
| 93 |
+
# return None
|
| 94 |
+
|
| 95 |
def show_simulation_results(chart_data):
|
| 96 |
+
try:
|
| 97 |
+
st.line_chart(chart_data, use_container_width=True, height=400)
|
| 98 |
+
except Exception as e:
|
| 99 |
+
st.error(f"Error plotting chart: {e}")
|
| 100 |
+
st.write("Chart data types:")
|
| 101 |
+
st.write(chart_data.dtypes)
|
| 102 |
+
st.write("Chart data head:")
|
| 103 |
+
st.write(chart_data.head())
|
| 104 |
+
st.write("Chart data description:")
|
| 105 |
+
st.write(chart_data.describe())
|
| 106 |
|
| 107 |
def show_mdf_graph(mdf_model):
|
| 108 |
st.subheader("MDF Graph")
|
|
|
|
| 117 |
def view_tabs(mdf_model, param_inputs): # view
|
| 118 |
tab1, tab2, tab3 = st.tabs(["Simulation Results", "MDF Graph", "Json Output"])
|
| 119 |
with tab1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
run_simulation(param_inputs, mdf_model) # model
|
|
|
|
| 121 |
with tab2:
|
| 122 |
show_mdf_graph(mdf_model) # view
|
| 123 |
with tab3:
|
| 124 |
show_json_output(mdf_model) # view
|
| 125 |
|
| 126 |
+
def display_and_edit_array(array, key):
|
| 127 |
+
if isinstance(array, list):
|
| 128 |
+
array = np.array(array)
|
| 129 |
+
|
| 130 |
+
rows, cols = array.shape if array.ndim > 1 else (1, len(array))
|
| 131 |
+
|
| 132 |
+
edited_array = []
|
| 133 |
+
for i in range(rows):
|
| 134 |
+
row = []
|
| 135 |
+
for j in range(cols):
|
| 136 |
+
value = array[i][j] if array.ndim > 1 else array[i]
|
| 137 |
+
edited_value = st.text_input(f"[{i}][{j}]", value=str(value), key=f"{key}_{i}_{j}")
|
| 138 |
+
try:
|
| 139 |
+
row.append(float(edited_value))
|
| 140 |
+
except ValueError:
|
| 141 |
+
st.error(f"Invalid input for [{i}][{j}]. Please enter a valid number.")
|
| 142 |
+
edited_array.append(row)
|
| 143 |
+
|
| 144 |
+
return np.array(edited_array)
|
| 145 |
+
|
| 146 |
def parameter_form_to_update_model_and_view(mdf_model, parameters, param_inputs, mod_graph, nodes):
|
| 147 |
with st.form(key="parameter_form"):
|
| 148 |
valid_inputs = True
|
|
|
|
| 160 |
current_col = col1 if i % 2 == 0 else col2
|
| 161 |
|
| 162 |
with current_col:
|
| 163 |
+
if isinstance(param.value, (list, np.ndarray)):
|
| 164 |
+
st.write(f"{param.id}:")
|
| 165 |
+
value = display_and_edit_array(param.value, key)
|
| 166 |
else:
|
| 167 |
+
if param.metadata:
|
| 168 |
+
value = st.text_input(f"{param.metadata.get('description', param.id)} ({param.id})", value=str(param.value), key=key)
|
| 169 |
+
else:
|
| 170 |
+
value = st.text_input(f"{param.id}", value=str(param.value), key=key)
|
| 171 |
+
try:
|
| 172 |
+
param_inputs[param.id] = float(value)
|
| 173 |
+
except ValueError:
|
| 174 |
+
st.error(f"Invalid input for {param.id}. Please enter a valid number.")
|
| 175 |
+
valid_inputs = False
|
| 176 |
|
| 177 |
+
param_inputs[param.id] = value
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
st.write("Simulation Parameters:")
|
| 179 |
with st.container(border=True):
|
| 180 |
# Add Simulation Duration and Time Step inputs
|
|
|
|
| 275 |
st.error(f"Error loading file from GitHub: {e}")
|
| 276 |
return None
|
| 277 |
# with col2:
|
| 278 |
+
# example_models = {
|
| 279 |
+
# "Newton Cooling Model": "https://raw.githubusercontent.com/ModECI/MDF/development/examples/MDF/NewtonCoolingModel.json",
|
| 280 |
+
# "ABCD": "https://raw.githubusercontent.com/ModECI/MDF/main/examples/MDF/ABCD.json",
|
| 281 |
+
# "FN": "https://raw.githubusercontent.com/ModECI/MDF/main/examples/MDF/FN.mdf.json",
|
| 282 |
+
# "States": "https://raw.githubusercontent.com/ModECI/MDF/main/examples/MDF/States.json",
|
| 283 |
+
# "Other Model 4": "https://example.com/other_model_4.json"
|
| 284 |
+
# }
|
| 285 |
+
# selected_model = st.selectbox("Choose an example model", list(example_models.keys()), index=None)
|
| 286 |
+
# if selected_model:
|
| 287 |
+
# example_url = example_models[selected_model]
|
| 288 |
+
# try:
|
| 289 |
+
# response = requests.get(example_url)
|
| 290 |
+
# response.raise_for_status()
|
| 291 |
+
# file_content = response.content
|
| 292 |
+
# file_extension = example_url.split('.')[-1].lower()
|
| 293 |
+
# return load_model_from_content(file_content, file_extension)
|
| 294 |
+
# except requests.RequestException as e:
|
| 295 |
+
# st.error(f"Error loading example model: {e}")
|
| 296 |
+
# return None
|
| 297 |
+
# # st.button("Newton Cooling Model", on_click=load_mdf_json(""))
|
| 298 |
+
# return None
|
| 299 |
example_models = {
|
| 300 |
+
"Newton Cooling Model": "./examples/NewtonCoolingModel.json",
|
| 301 |
+
# "ABCD": "./examples/ABCD.json",
|
| 302 |
+
"FN": "./examples/FN.mdf.json",
|
| 303 |
+
# "States": "./examples/States.json",
|
| 304 |
+
"Swicthed RLC Circuit": "./examples/switched_rlc_circuit.json",
|
| 305 |
+
# "Arrays":"./examples/Arrays.json",
|
| 306 |
+
# "RNN":"./examples/RNNs.json",
|
| 307 |
+
# "IAF":"./examples/IAFs.json"
|
| 308 |
}
|
| 309 |
selected_model = st.selectbox("Choose an example model", list(example_models.keys()), index=None)
|
| 310 |
if selected_model:
|
| 311 |
+
return load_mdf_json(example_models[selected_model])
|
| 312 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
|
| 314 |
|
| 315 |
def load_model_from_content(file_content, file_extension):
|
examples/ABCD.json
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"ABCD": {
|
| 3 |
+
"format": "ModECI MDF v0.4",
|
| 4 |
+
"generating_application": "Python modeci-mdf v0.4.10",
|
| 5 |
+
"graphs": {
|
| 6 |
+
"abcd_example": {
|
| 7 |
+
"nodes": {
|
| 8 |
+
"input0": {
|
| 9 |
+
"metadata": {
|
| 10 |
+
"color": ".8 .8 .8"
|
| 11 |
+
},
|
| 12 |
+
"parameters": {
|
| 13 |
+
"input_level": {
|
| 14 |
+
"value": 0.0
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"output_ports": {
|
| 18 |
+
"out_port": {
|
| 19 |
+
"value": "input_level"
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
"A": {
|
| 24 |
+
"metadata": {
|
| 25 |
+
"color": ".8 0 0"
|
| 26 |
+
},
|
| 27 |
+
"input_ports": {
|
| 28 |
+
"input_port1": {}
|
| 29 |
+
},
|
| 30 |
+
"parameters": {
|
| 31 |
+
"slope": {
|
| 32 |
+
"value": 1.1
|
| 33 |
+
},
|
| 34 |
+
"intercept": {
|
| 35 |
+
"value": 1.2
|
| 36 |
+
},
|
| 37 |
+
"linear_func": {
|
| 38 |
+
"function": "linear",
|
| 39 |
+
"args": {
|
| 40 |
+
"variable0": "input_port1",
|
| 41 |
+
"slope": "slope",
|
| 42 |
+
"intercept": "intercept"
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
},
|
| 46 |
+
"output_ports": {
|
| 47 |
+
"out_port": {
|
| 48 |
+
"value": "linear_func"
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
},
|
| 52 |
+
"B": {
|
| 53 |
+
"metadata": {
|
| 54 |
+
"color": "0 .8 0"
|
| 55 |
+
},
|
| 56 |
+
"input_ports": {
|
| 57 |
+
"input_port1": {}
|
| 58 |
+
},
|
| 59 |
+
"parameters": {
|
| 60 |
+
"gain": {
|
| 61 |
+
"value": 2.1
|
| 62 |
+
},
|
| 63 |
+
"bias": {
|
| 64 |
+
"value": 2.2
|
| 65 |
+
},
|
| 66 |
+
"offset": {
|
| 67 |
+
"value": 2.3
|
| 68 |
+
},
|
| 69 |
+
"logistic_func": {
|
| 70 |
+
"function": "logistic",
|
| 71 |
+
"args": {
|
| 72 |
+
"variable0": "input_port1",
|
| 73 |
+
"gain": "gain",
|
| 74 |
+
"bias": "bias",
|
| 75 |
+
"offset": "offset"
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
},
|
| 79 |
+
"output_ports": {
|
| 80 |
+
"out_port": {
|
| 81 |
+
"value": "logistic_func"
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
},
|
| 85 |
+
"C": {
|
| 86 |
+
"metadata": {
|
| 87 |
+
"color": "0 0 .8"
|
| 88 |
+
},
|
| 89 |
+
"input_ports": {
|
| 90 |
+
"input_port1": {
|
| 91 |
+
"shape": [
|
| 92 |
+
1
|
| 93 |
+
]
|
| 94 |
+
}
|
| 95 |
+
},
|
| 96 |
+
"parameters": {
|
| 97 |
+
"scale": {
|
| 98 |
+
"value": 3.1
|
| 99 |
+
},
|
| 100 |
+
"rate": {
|
| 101 |
+
"value": 3.2
|
| 102 |
+
},
|
| 103 |
+
"bias": {
|
| 104 |
+
"value": 3.3
|
| 105 |
+
},
|
| 106 |
+
"offset": {
|
| 107 |
+
"value": 3.4
|
| 108 |
+
},
|
| 109 |
+
"exponential_func": {
|
| 110 |
+
"function": "exponential",
|
| 111 |
+
"args": {
|
| 112 |
+
"variable0": "input_port1",
|
| 113 |
+
"scale": "scale",
|
| 114 |
+
"rate": "rate",
|
| 115 |
+
"bias": "bias",
|
| 116 |
+
"offset": "offset"
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
},
|
| 120 |
+
"output_ports": {
|
| 121 |
+
"out_port": {
|
| 122 |
+
"value": "exponential_func"
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
"D": {
|
| 127 |
+
"metadata": {
|
| 128 |
+
"color": ".8 0 .8"
|
| 129 |
+
},
|
| 130 |
+
"input_ports": {
|
| 131 |
+
"input_port1": {
|
| 132 |
+
"shape": [
|
| 133 |
+
1
|
| 134 |
+
]
|
| 135 |
+
}
|
| 136 |
+
},
|
| 137 |
+
"parameters": {
|
| 138 |
+
"scale": {
|
| 139 |
+
"value": 4.0
|
| 140 |
+
},
|
| 141 |
+
"sin_func": {
|
| 142 |
+
"function": "sin",
|
| 143 |
+
"args": {
|
| 144 |
+
"variable0": "input_port1",
|
| 145 |
+
"scale": "scale"
|
| 146 |
+
}
|
| 147 |
+
}
|
| 148 |
+
},
|
| 149 |
+
"output_ports": {
|
| 150 |
+
"out_port": {
|
| 151 |
+
"value": "sin_func"
|
| 152 |
+
}
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
},
|
| 156 |
+
"edges": {
|
| 157 |
+
"edge_input0_A": {
|
| 158 |
+
"sender": "input0",
|
| 159 |
+
"receiver": "A",
|
| 160 |
+
"sender_port": "out_port",
|
| 161 |
+
"receiver_port": "input_port1"
|
| 162 |
+
},
|
| 163 |
+
"edge_A_B": {
|
| 164 |
+
"sender": "A",
|
| 165 |
+
"receiver": "B",
|
| 166 |
+
"sender_port": "out_port",
|
| 167 |
+
"receiver_port": "input_port1"
|
| 168 |
+
},
|
| 169 |
+
"edge_B_C": {
|
| 170 |
+
"sender": "B",
|
| 171 |
+
"receiver": "C",
|
| 172 |
+
"sender_port": "out_port",
|
| 173 |
+
"receiver_port": "input_port1"
|
| 174 |
+
},
|
| 175 |
+
"edge_C_D": {
|
| 176 |
+
"sender": "C",
|
| 177 |
+
"receiver": "D",
|
| 178 |
+
"sender_port": "out_port",
|
| 179 |
+
"receiver_port": "input_port1"
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
}
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
}
|
examples/Arrays.json
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"Arrays": {
|
| 3 |
+
"format": "ModECI MDF v0.4",
|
| 4 |
+
"generating_application": "Python modeci-mdf v0.4.11",
|
| 5 |
+
"graphs": {
|
| 6 |
+
"array_example": {
|
| 7 |
+
"nodes": {
|
| 8 |
+
"input_node": {
|
| 9 |
+
"parameters": {
|
| 10 |
+
"input_level": {
|
| 11 |
+
"value": [
|
| 12 |
+
[
|
| 13 |
+
1,
|
| 14 |
+
2.0
|
| 15 |
+
],
|
| 16 |
+
[
|
| 17 |
+
3,
|
| 18 |
+
4
|
| 19 |
+
]
|
| 20 |
+
]
|
| 21 |
+
}
|
| 22 |
+
},
|
| 23 |
+
"output_ports": {
|
| 24 |
+
"out_port": {
|
| 25 |
+
"value": "input_level"
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
},
|
| 29 |
+
"middle_node": {
|
| 30 |
+
"input_ports": {
|
| 31 |
+
"input_port1": {
|
| 32 |
+
"shape": [
|
| 33 |
+
2,
|
| 34 |
+
2
|
| 35 |
+
]
|
| 36 |
+
}
|
| 37 |
+
},
|
| 38 |
+
"parameters": {
|
| 39 |
+
"slope": {
|
| 40 |
+
"value": 0.5
|
| 41 |
+
},
|
| 42 |
+
"intercept": {
|
| 43 |
+
"value": [
|
| 44 |
+
[
|
| 45 |
+
0.0,
|
| 46 |
+
1.0
|
| 47 |
+
],
|
| 48 |
+
[
|
| 49 |
+
2.0,
|
| 50 |
+
2.0
|
| 51 |
+
]
|
| 52 |
+
]
|
| 53 |
+
},
|
| 54 |
+
"linear_1": {
|
| 55 |
+
"function": "linear",
|
| 56 |
+
"args": {
|
| 57 |
+
"variable0": "input_port1",
|
| 58 |
+
"slope": "slope",
|
| 59 |
+
"intercept": "intercept"
|
| 60 |
+
}
|
| 61 |
+
}
|
| 62 |
+
},
|
| 63 |
+
"output_ports": {
|
| 64 |
+
"output_1": {
|
| 65 |
+
"value": "linear_1"
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
"edges": {
|
| 71 |
+
"input_edge": {
|
| 72 |
+
"sender": "input_node",
|
| 73 |
+
"receiver": "middle_node",
|
| 74 |
+
"sender_port": "out_port",
|
| 75 |
+
"receiver_port": "input_port1",
|
| 76 |
+
"parameters": {
|
| 77 |
+
"weight": [
|
| 78 |
+
[
|
| 79 |
+
1,
|
| 80 |
+
0
|
| 81 |
+
],
|
| 82 |
+
[
|
| 83 |
+
0,
|
| 84 |
+
1
|
| 85 |
+
]
|
| 86 |
+
]
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
}
|
| 93 |
+
}
|
examples/FN.mdf.json
CHANGED
|
@@ -1,6 +1,10 @@
|
|
| 1 |
{
|
| 2 |
"FN": {
|
| 3 |
"format": "ModECI MDF v0.4",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
"graphs": {
|
| 5 |
"FN": {
|
| 6 |
"notes": "FitzHugh Nagumo cell model - originally specified in NeuroML/LEMS",
|
|
|
|
| 1 |
{
|
| 2 |
"FN": {
|
| 3 |
"format": "ModECI MDF v0.4",
|
| 4 |
+
"metadata": {
|
| 5 |
+
"preferred_duration": 0.1,
|
| 6 |
+
"preferred_dt": 0.00005
|
| 7 |
+
},
|
| 8 |
"graphs": {
|
| 9 |
"FN": {
|
| 10 |
"notes": "FitzHugh Nagumo cell model - originally specified in NeuroML/LEMS",
|
examples/IAFs.json
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"IAFs": {
|
| 3 |
+
"format": "ModECI MDF v0.4",
|
| 4 |
+
"generating_application": "Python modeci-mdf v0.4.11",
|
| 5 |
+
"metadata": {
|
| 6 |
+
"preferred_duration": 100,
|
| 7 |
+
"preferred_dt": 0.1
|
| 8 |
+
},
|
| 9 |
+
"graphs": {
|
| 10 |
+
"IAFs": {
|
| 11 |
+
"nodes": {
|
| 12 |
+
"current_input_node": {
|
| 13 |
+
"parameters": {
|
| 14 |
+
"time": {
|
| 15 |
+
"default_initial_value": 0,
|
| 16 |
+
"time_derivative": "1"
|
| 17 |
+
},
|
| 18 |
+
"start": {
|
| 19 |
+
"value": 20
|
| 20 |
+
},
|
| 21 |
+
"duration": {
|
| 22 |
+
"value": 60
|
| 23 |
+
},
|
| 24 |
+
"amplitude": {
|
| 25 |
+
"value": 10
|
| 26 |
+
},
|
| 27 |
+
"level": {
|
| 28 |
+
"value": 0,
|
| 29 |
+
"conditions": [
|
| 30 |
+
{
|
| 31 |
+
"id": "on",
|
| 32 |
+
"test": "time > start",
|
| 33 |
+
"value": "amplitude"
|
| 34 |
+
},
|
| 35 |
+
{
|
| 36 |
+
"id": "off",
|
| 37 |
+
"test": "time > start + duration",
|
| 38 |
+
"value": "amplitude*0"
|
| 39 |
+
}
|
| 40 |
+
]
|
| 41 |
+
}
|
| 42 |
+
},
|
| 43 |
+
"output_ports": {
|
| 44 |
+
"current_output": {
|
| 45 |
+
"value": "level"
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
},
|
| 49 |
+
"pre": {
|
| 50 |
+
"input_ports": {
|
| 51 |
+
"current_input": {
|
| 52 |
+
"shape": [
|
| 53 |
+
1
|
| 54 |
+
]
|
| 55 |
+
}
|
| 56 |
+
},
|
| 57 |
+
"parameters": {
|
| 58 |
+
"v0": {
|
| 59 |
+
"value": [
|
| 60 |
+
-60
|
| 61 |
+
]
|
| 62 |
+
},
|
| 63 |
+
"erev": {
|
| 64 |
+
"value": [
|
| 65 |
+
-70
|
| 66 |
+
]
|
| 67 |
+
},
|
| 68 |
+
"tau": {
|
| 69 |
+
"value": 10.0
|
| 70 |
+
},
|
| 71 |
+
"thresh": {
|
| 72 |
+
"value": [
|
| 73 |
+
-20
|
| 74 |
+
]
|
| 75 |
+
},
|
| 76 |
+
"spiking": {
|
| 77 |
+
"default_initial_value": "0",
|
| 78 |
+
"conditions": [
|
| 79 |
+
{
|
| 80 |
+
"id": "is_spiking",
|
| 81 |
+
"test": "v >= thresh",
|
| 82 |
+
"value": "1"
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"id": "not_spiking",
|
| 86 |
+
"test": "v < thresh",
|
| 87 |
+
"value": "0"
|
| 88 |
+
}
|
| 89 |
+
]
|
| 90 |
+
},
|
| 91 |
+
"v": {
|
| 92 |
+
"default_initial_value": "v0",
|
| 93 |
+
"time_derivative": "-1 * (v-erev)/tau + current_input",
|
| 94 |
+
"conditions": [
|
| 95 |
+
{
|
| 96 |
+
"id": "reset",
|
| 97 |
+
"test": "v > thresh",
|
| 98 |
+
"value": "erev"
|
| 99 |
+
}
|
| 100 |
+
]
|
| 101 |
+
}
|
| 102 |
+
},
|
| 103 |
+
"output_ports": {
|
| 104 |
+
"v_output": {
|
| 105 |
+
"value": "v"
|
| 106 |
+
},
|
| 107 |
+
"spiking_output": {
|
| 108 |
+
"value": "spiking"
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
},
|
| 112 |
+
"post": {
|
| 113 |
+
"input_ports": {
|
| 114 |
+
"current_input": {
|
| 115 |
+
"shape": [
|
| 116 |
+
1
|
| 117 |
+
]
|
| 118 |
+
}
|
| 119 |
+
},
|
| 120 |
+
"parameters": {
|
| 121 |
+
"v0": {
|
| 122 |
+
"value": [
|
| 123 |
+
-60
|
| 124 |
+
]
|
| 125 |
+
},
|
| 126 |
+
"erev": {
|
| 127 |
+
"value": [
|
| 128 |
+
-70
|
| 129 |
+
]
|
| 130 |
+
},
|
| 131 |
+
"tau": {
|
| 132 |
+
"value": 10.0
|
| 133 |
+
},
|
| 134 |
+
"thresh": {
|
| 135 |
+
"value": [
|
| 136 |
+
-20
|
| 137 |
+
]
|
| 138 |
+
},
|
| 139 |
+
"spiking": {
|
| 140 |
+
"default_initial_value": "0",
|
| 141 |
+
"conditions": [
|
| 142 |
+
{
|
| 143 |
+
"id": "is_spiking",
|
| 144 |
+
"test": "v >= thresh",
|
| 145 |
+
"value": "1"
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"id": "not_spiking",
|
| 149 |
+
"test": "v < thresh",
|
| 150 |
+
"value": "0"
|
| 151 |
+
}
|
| 152 |
+
]
|
| 153 |
+
},
|
| 154 |
+
"v": {
|
| 155 |
+
"default_initial_value": "v0",
|
| 156 |
+
"time_derivative": "-1 * (v-erev)/tau + current_input",
|
| 157 |
+
"conditions": [
|
| 158 |
+
{
|
| 159 |
+
"id": "reset",
|
| 160 |
+
"test": "v > thresh",
|
| 161 |
+
"value": "erev"
|
| 162 |
+
}
|
| 163 |
+
]
|
| 164 |
+
}
|
| 165 |
+
},
|
| 166 |
+
"output_ports": {
|
| 167 |
+
"v_output": {
|
| 168 |
+
"value": "v"
|
| 169 |
+
},
|
| 170 |
+
"spiking_output": {
|
| 171 |
+
"value": "spiking"
|
| 172 |
+
}
|
| 173 |
+
}
|
| 174 |
+
},
|
| 175 |
+
"syn_post": {
|
| 176 |
+
"input_ports": {
|
| 177 |
+
"spike_input": {
|
| 178 |
+
"shape": [
|
| 179 |
+
1
|
| 180 |
+
]
|
| 181 |
+
}
|
| 182 |
+
},
|
| 183 |
+
"parameters": {
|
| 184 |
+
"syn_tau": {
|
| 185 |
+
"value": 10
|
| 186 |
+
},
|
| 187 |
+
"spike_weights": {
|
| 188 |
+
"value": [
|
| 189 |
+
40
|
| 190 |
+
]
|
| 191 |
+
},
|
| 192 |
+
"weighted_spike": {
|
| 193 |
+
"function": "MatMul",
|
| 194 |
+
"args": {
|
| 195 |
+
"A": "spike_weights",
|
| 196 |
+
"B": "spike_input"
|
| 197 |
+
}
|
| 198 |
+
},
|
| 199 |
+
"syn_i": {
|
| 200 |
+
"default_initial_value": "0",
|
| 201 |
+
"time_derivative": "-1 * syn_i",
|
| 202 |
+
"conditions": [
|
| 203 |
+
{
|
| 204 |
+
"id": "spike_detected",
|
| 205 |
+
"test": "spike_input > 0",
|
| 206 |
+
"value": "weighted_spike"
|
| 207 |
+
}
|
| 208 |
+
]
|
| 209 |
+
}
|
| 210 |
+
},
|
| 211 |
+
"output_ports": {
|
| 212 |
+
"current_output": {
|
| 213 |
+
"value": "syn_i"
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
}
|
| 217 |
+
},
|
| 218 |
+
"edges": {
|
| 219 |
+
"input_edge": {
|
| 220 |
+
"sender": "current_input_node",
|
| 221 |
+
"receiver": "pre",
|
| 222 |
+
"sender_port": "current_output",
|
| 223 |
+
"receiver_port": "current_input"
|
| 224 |
+
},
|
| 225 |
+
"post_internal_edge": {
|
| 226 |
+
"sender": "syn_post",
|
| 227 |
+
"receiver": "post",
|
| 228 |
+
"sender_port": "current_output",
|
| 229 |
+
"receiver_port": "current_input"
|
| 230 |
+
},
|
| 231 |
+
"syn_edge": {
|
| 232 |
+
"sender": "pre",
|
| 233 |
+
"receiver": "syn_post",
|
| 234 |
+
"sender_port": "spiking_output",
|
| 235 |
+
"receiver_port": "spike_input"
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
}
|
| 239 |
+
}
|
| 240 |
+
}
|
| 241 |
+
}
|
examples/NewtonCoolingModel.json
CHANGED
|
@@ -2,22 +2,38 @@
|
|
| 2 |
"NewtonCoolingModel": {
|
| 3 |
"format": "ModECI MDF v0.4",
|
| 4 |
"generating_application": "Python modeci-mdf v0.4.11",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
"graphs": {
|
| 6 |
-
"
|
| 7 |
"nodes": {
|
| 8 |
"cool_node": {
|
| 9 |
"parameters": {
|
| 10 |
"cooling_coeff": {
|
|
|
|
|
|
|
|
|
|
| 11 |
"value": 0.1
|
| 12 |
},
|
| 13 |
"T_a": {
|
|
|
|
|
|
|
|
|
|
| 14 |
"value": 20
|
| 15 |
},
|
| 16 |
"T_curr": {
|
|
|
|
|
|
|
|
|
|
| 17 |
"default_initial_value": 90,
|
| 18 |
"time_derivative": "dT_dt"
|
| 19 |
},
|
| 20 |
"dT_dt": {
|
|
|
|
|
|
|
|
|
|
| 21 |
"value": "-cooling_coeff*(T_curr - T_a)",
|
| 22 |
"default_initial_value": 0
|
| 23 |
}
|
|
@@ -35,4 +51,4 @@
|
|
| 35 |
}
|
| 36 |
}
|
| 37 |
}
|
| 38 |
-
}
|
|
|
|
| 2 |
"NewtonCoolingModel": {
|
| 3 |
"format": "ModECI MDF v0.4",
|
| 4 |
"generating_application": "Python modeci-mdf v0.4.11",
|
| 5 |
+
"metadata": {
|
| 6 |
+
"preferred_duration": 100,
|
| 7 |
+
"preferred_dt": 0.01
|
| 8 |
+
},
|
| 9 |
"graphs": {
|
| 10 |
+
"NewtonCoolingModel": {
|
| 11 |
"nodes": {
|
| 12 |
"cool_node": {
|
| 13 |
"parameters": {
|
| 14 |
"cooling_coeff": {
|
| 15 |
+
"metadata": {
|
| 16 |
+
"description": "Cooling coefficient in 1/s"
|
| 17 |
+
},
|
| 18 |
"value": 0.1
|
| 19 |
},
|
| 20 |
"T_a": {
|
| 21 |
+
"metadata": {
|
| 22 |
+
"description": "Ambient temperature in degrees C"
|
| 23 |
+
},
|
| 24 |
"value": 20
|
| 25 |
},
|
| 26 |
"T_curr": {
|
| 27 |
+
"metadata": {
|
| 28 |
+
"description": "Current temperature in degrees C"
|
| 29 |
+
},
|
| 30 |
"default_initial_value": 90,
|
| 31 |
"time_derivative": "dT_dt"
|
| 32 |
},
|
| 33 |
"dT_dt": {
|
| 34 |
+
"metadata": {
|
| 35 |
+
"description": "Rate of change of temperature in degrees C/s"
|
| 36 |
+
},
|
| 37 |
"value": "-cooling_coeff*(T_curr - T_a)",
|
| 38 |
"default_initial_value": 0
|
| 39 |
}
|
|
|
|
| 51 |
}
|
| 52 |
}
|
| 53 |
}
|
| 54 |
+
}
|
examples/RNNs.json
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"RNNs": {
|
| 3 |
+
"format": "ModECI MDF v0.4",
|
| 4 |
+
"generating_application": "Python modeci-mdf v0.4.11",
|
| 5 |
+
"metadata": {
|
| 6 |
+
"preferred_duration": 50,
|
| 7 |
+
"preferred_dt": 0.1
|
| 8 |
+
},
|
| 9 |
+
"graphs": {
|
| 10 |
+
"RNNs": {
|
| 11 |
+
"nodes": {
|
| 12 |
+
"input_node": {
|
| 13 |
+
"parameters": {
|
| 14 |
+
"t": {
|
| 15 |
+
"default_initial_value": 0,
|
| 16 |
+
"time_derivative": "1"
|
| 17 |
+
},
|
| 18 |
+
"amplitude": {
|
| 19 |
+
"value": [
|
| 20 |
+
1
|
| 21 |
+
]
|
| 22 |
+
},
|
| 23 |
+
"period": {
|
| 24 |
+
"value": [
|
| 25 |
+
10
|
| 26 |
+
]
|
| 27 |
+
},
|
| 28 |
+
"level": {
|
| 29 |
+
"function": "sin",
|
| 30 |
+
"args": {
|
| 31 |
+
"variable0": "2*3.14159*t/period",
|
| 32 |
+
"scale": "amplitude"
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
},
|
| 36 |
+
"output_ports": {
|
| 37 |
+
"out_port": {
|
| 38 |
+
"value": "level"
|
| 39 |
+
},
|
| 40 |
+
"t_out_port": {
|
| 41 |
+
"value": "t"
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
},
|
| 45 |
+
"rnn_node": {
|
| 46 |
+
"input_ports": {
|
| 47 |
+
"ext_input": {
|
| 48 |
+
"shape": [
|
| 49 |
+
5
|
| 50 |
+
]
|
| 51 |
+
},
|
| 52 |
+
"fb_input": {
|
| 53 |
+
"shape": [
|
| 54 |
+
5
|
| 55 |
+
]
|
| 56 |
+
}
|
| 57 |
+
},
|
| 58 |
+
"parameters": {
|
| 59 |
+
"M": {
|
| 60 |
+
"value": [
|
| 61 |
+
[
|
| 62 |
+
-0.15378707975107808,
|
| 63 |
+
0.961528396769231,
|
| 64 |
+
0.3696594771697266,
|
| 65 |
+
-0.03813619703127813,
|
| 66 |
+
-0.21576496361169895
|
| 67 |
+
],
|
| 68 |
+
[
|
| 69 |
+
-0.3136439676982612,
|
| 70 |
+
0.45809941476808325,
|
| 71 |
+
-0.12285551064075118,
|
| 72 |
+
-0.8806442067808633,
|
| 73 |
+
-0.20391148933913716
|
| 74 |
+
],
|
| 75 |
+
[
|
| 76 |
+
0.4759908114640714,
|
| 77 |
+
-0.635016539093,
|
| 78 |
+
-0.6490964877050149,
|
| 79 |
+
0.06310274768367674,
|
| 80 |
+
0.06365517419373212
|
| 81 |
+
],
|
| 82 |
+
[
|
| 83 |
+
0.2688019171026421,
|
| 84 |
+
0.6988635881555791,
|
| 85 |
+
0.4489106497212705,
|
| 86 |
+
0.22204702135516574,
|
| 87 |
+
0.4448867651404431
|
| 88 |
+
],
|
| 89 |
+
[
|
| 90 |
+
-0.3540821722936436,
|
| 91 |
+
-0.2764226887553718,
|
| 92 |
+
-0.5434735382420888,
|
| 93 |
+
-0.41257190722234127,
|
| 94 |
+
0.2619522477089755
|
| 95 |
+
]
|
| 96 |
+
]
|
| 97 |
+
},
|
| 98 |
+
"g": {
|
| 99 |
+
"value": 1.5
|
| 100 |
+
},
|
| 101 |
+
"x": {
|
| 102 |
+
"default_initial_value": [
|
| 103 |
+
0.3929383711957233,
|
| 104 |
+
-0.42772133009924107,
|
| 105 |
+
-0.5462970928715938,
|
| 106 |
+
0.10262953816578246,
|
| 107 |
+
0.43893793957112615
|
| 108 |
+
],
|
| 109 |
+
"time_derivative": "-x + g*int_fb + ext_input"
|
| 110 |
+
},
|
| 111 |
+
"r": {
|
| 112 |
+
"function": "tanh",
|
| 113 |
+
"args": {
|
| 114 |
+
"variable0": "x",
|
| 115 |
+
"scale": 1
|
| 116 |
+
}
|
| 117 |
+
},
|
| 118 |
+
"int_fb": {
|
| 119 |
+
"function": "MatMul",
|
| 120 |
+
"args": {
|
| 121 |
+
"A": "M",
|
| 122 |
+
"B": "r"
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
+
},
|
| 126 |
+
"output_ports": {
|
| 127 |
+
"out_port_x": {
|
| 128 |
+
"value": "x"
|
| 129 |
+
},
|
| 130 |
+
"out_port_r": {
|
| 131 |
+
"value": "r"
|
| 132 |
+
}
|
| 133 |
+
}
|
| 134 |
+
},
|
| 135 |
+
"readout_node": {
|
| 136 |
+
"input_ports": {
|
| 137 |
+
"input": {
|
| 138 |
+
"shape": [
|
| 139 |
+
5
|
| 140 |
+
]
|
| 141 |
+
}
|
| 142 |
+
},
|
| 143 |
+
"parameters": {
|
| 144 |
+
"wr": {
|
| 145 |
+
"value": [
|
| 146 |
+
1.0,
|
| 147 |
+
1.0,
|
| 148 |
+
1.0,
|
| 149 |
+
1.0,
|
| 150 |
+
1.0
|
| 151 |
+
]
|
| 152 |
+
},
|
| 153 |
+
"zi": {
|
| 154 |
+
"function": "MatMul",
|
| 155 |
+
"args": {
|
| 156 |
+
"A": "input",
|
| 157 |
+
"B": "wr"
|
| 158 |
+
}
|
| 159 |
+
}
|
| 160 |
+
},
|
| 161 |
+
"output_ports": {
|
| 162 |
+
"z": {
|
| 163 |
+
"value": "zi"
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
},
|
| 168 |
+
"edges": {
|
| 169 |
+
"input_edge": {
|
| 170 |
+
"sender": "input_node",
|
| 171 |
+
"receiver": "rnn_node",
|
| 172 |
+
"sender_port": "out_port",
|
| 173 |
+
"receiver_port": "ext_input",
|
| 174 |
+
"parameters": {
|
| 175 |
+
"weight": [
|
| 176 |
+
1.0,
|
| 177 |
+
0.0,
|
| 178 |
+
0.0,
|
| 179 |
+
0.0,
|
| 180 |
+
0.0
|
| 181 |
+
]
|
| 182 |
+
}
|
| 183 |
+
},
|
| 184 |
+
"readout_edge": {
|
| 185 |
+
"sender": "rnn_node",
|
| 186 |
+
"receiver": "readout_node",
|
| 187 |
+
"sender_port": "out_port_r",
|
| 188 |
+
"receiver_port": "input",
|
| 189 |
+
"parameters": {
|
| 190 |
+
"weight": 1
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
}
|
| 194 |
+
}
|
| 195 |
+
}
|
| 196 |
+
}
|
| 197 |
+
}
|
examples/{SwitchedRLC_Circuit.json → switched_rlc_circuit.json}
RENAMED
|
@@ -1,29 +1,21 @@
|
|
| 1 |
-
{
|
| 2 |
"SwitchedRLC_Circuit": {
|
|
|
|
| 3 |
"format": "ModECI MDF v0.4",
|
| 4 |
-
"generating_application": "Python modeci-mdf v0.4.
|
| 5 |
"metadata": {
|
| 6 |
"preferred_duration": 2,
|
| 7 |
"preferred_dt": 0.001
|
| 8 |
},
|
| 9 |
"graphs": {
|
|
|
|
| 10 |
"SwitchedRLC_Circuit": {
|
| 11 |
"nodes": {
|
|
|
|
| 12 |
"V": {
|
| 13 |
"parameters": {
|
| 14 |
"Vs": {
|
| 15 |
-
"
|
| 16 |
-
{
|
| 17 |
-
"id": "off",
|
| 18 |
-
"test": "time<0.5",
|
| 19 |
-
"value": "0"
|
| 20 |
-
},
|
| 21 |
-
{
|
| 22 |
-
"id": "on",
|
| 23 |
-
"test": "time>=0.5",
|
| 24 |
-
"value": 0.1
|
| 25 |
-
}
|
| 26 |
-
]
|
| 27 |
},
|
| 28 |
"R": {
|
| 29 |
"metadata": {
|
|
@@ -38,6 +30,9 @@
|
|
| 38 |
"value": 1
|
| 39 |
},
|
| 40 |
"C": {
|
|
|
|
|
|
|
|
|
|
| 41 |
"value": 0.001
|
| 42 |
},
|
| 43 |
"time": {
|
|
@@ -45,17 +40,33 @@
|
|
| 45 |
"time_derivative": "1"
|
| 46 |
},
|
| 47 |
"V": {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
"default_initial_value": 0,
|
| 49 |
"time_derivative": "i_C /C"
|
| 50 |
},
|
| 51 |
"i_R": {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
"value": "V / R"
|
| 53 |
},
|
| 54 |
"i_L": {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
"default_initial_value": 0,
|
| 56 |
"time_derivative": "(Vs - V)/L"
|
| 57 |
},
|
| 58 |
"i_C": {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
"value": "i_L-i_R"
|
| 60 |
}
|
| 61 |
},
|
|
@@ -66,10 +77,14 @@
|
|
| 66 |
"i_L_out": {
|
| 67 |
"value": "i_L"
|
| 68 |
}
|
|
|
|
| 69 |
}
|
| 70 |
}
|
| 71 |
}
|
|
|
|
| 72 |
}
|
|
|
|
|
|
|
| 73 |
}
|
| 74 |
}
|
| 75 |
}
|
|
|
|
| 1 |
+
{
|
| 2 |
"SwitchedRLC_Circuit": {
|
| 3 |
+
|
| 4 |
"format": "ModECI MDF v0.4",
|
| 5 |
+
"generating_application": "Python modeci-mdf v0.4.10",
|
| 6 |
"metadata": {
|
| 7 |
"preferred_duration": 2,
|
| 8 |
"preferred_dt": 0.001
|
| 9 |
},
|
| 10 |
"graphs": {
|
| 11 |
+
|
| 12 |
"SwitchedRLC_Circuit": {
|
| 13 |
"nodes": {
|
| 14 |
+
|
| 15 |
"V": {
|
| 16 |
"parameters": {
|
| 17 |
"Vs": {
|
| 18 |
+
"value":"0.5"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
},
|
| 20 |
"R": {
|
| 21 |
"metadata": {
|
|
|
|
| 30 |
"value": 1
|
| 31 |
},
|
| 32 |
"C": {
|
| 33 |
+
"metadata": {
|
| 34 |
+
"description": "Capacitance in Farads"
|
| 35 |
+
},
|
| 36 |
"value": 0.001
|
| 37 |
},
|
| 38 |
"time": {
|
|
|
|
| 40 |
"time_derivative": "1"
|
| 41 |
},
|
| 42 |
"V": {
|
| 43 |
+
"metadata": {
|
| 44 |
+
"description": "Voltage across the circuit",
|
| 45 |
+
"plot":"True"
|
| 46 |
+
},
|
| 47 |
"default_initial_value": 0,
|
| 48 |
"time_derivative": "i_C /C"
|
| 49 |
},
|
| 50 |
"i_R": {
|
| 51 |
+
"metadata": {
|
| 52 |
+
"description": "Current through the resistor",
|
| 53 |
+
"plot":"True"
|
| 54 |
+
},
|
| 55 |
"value": "V / R"
|
| 56 |
},
|
| 57 |
"i_L": {
|
| 58 |
+
"metadata": {
|
| 59 |
+
"description": "Current through the inductor",
|
| 60 |
+
"plot":"True"
|
| 61 |
+
},
|
| 62 |
"default_initial_value": 0,
|
| 63 |
"time_derivative": "(Vs - V)/L"
|
| 64 |
},
|
| 65 |
"i_C": {
|
| 66 |
+
"metadata": {
|
| 67 |
+
"description": "Current through the capacitor",
|
| 68 |
+
"plot":"True"
|
| 69 |
+
},
|
| 70 |
"value": "i_L-i_R"
|
| 71 |
}
|
| 72 |
},
|
|
|
|
| 77 |
"i_L_out": {
|
| 78 |
"value": "i_L"
|
| 79 |
}
|
| 80 |
+
|
| 81 |
}
|
| 82 |
}
|
| 83 |
}
|
| 84 |
+
|
| 85 |
}
|
| 86 |
+
|
| 87 |
+
|
| 88 |
}
|
| 89 |
}
|
| 90 |
}
|