Skip to content

Instantly share code, notes, and snippets.

@eak24
Last active March 20, 2018 20:36
Show Gist options
  • Save eak24/7c29faebae4f2a4906fead713a86d391 to your computer and use it in GitHub Desktop.
Save eak24/7c29faebae4f2a4906fead713a86d391 to your computer and use it in GitHub Desktop.
meeting_3_20
{% macro render() %}{% include "ET.yaml"%}{% endmacro %}
# inputs which will be passed in explicitly later: OD_ent_pipe, q, temp, depth_end
{% set L_ET_max = opt.L_ET_MAX %} # optional input
{% set SDR_drain = 26 %} # materials database
# calculate drain diameter
{% set OD_drain = ent.drain_OD(q, temp, depth_end, SDR_drain) %}
# calculate number of plates and length
{% set num_plates = ent.num_plates_ET(q, W_chan) %}
{% set L_plate = ent.L_plate_ET(q, W_chan) %}
{% set materials = aide_render(materials.yaml) %}
# materials.yaml
---
a: {{ b }}
b: {{ c }}
c: {{ a }}
---
{% set constants = aide_render(strip_jinja(constants.yaml)) %}
# aide_render.render(template_name: str, context_dict: dict)-> dict:
# First render non-jinja variables and inject into the current namespace with aide_render.render
{% set ent_tank = aide_render.render(ent_tank) %}
# equivalent in jinja: {{ ent_tank["constants"]["vel_capture"] }} === {{ ent_tank.ent_tank.constants.vel_capture }}
#pipe.yaml
---
---
{% set conduction_line = aide_render.render(pipe) %}
{{ conduction_line.L }}
{{ }} -> evaluates the python commands and prints the result
{% %} -> evaluates the python commands
ent_tank: # delete this because it is redundant
cp:
L_max : 2.2 m
PIPE_ROUGH_PVC : {{ materials.PIPE_ROUGH_PVC }}
K_MINOR_PIPE_ENTRANCE : {{ constants.K_MINOR_PIPE_ENTRANCE }}
K_MINOR_PIPE_EXIT : {{ constants.K_MINOR_PIPE_EXIT }}
K_MINOR_EL90 : {{ constants.K_MINOR_EL90 }}
S_plate : 2.5 cm
B_plate : {{ constants.S_plate + materials.THICKNESS_ENT_TANK_PLATE }}
vel_capture : 8 millimeter/second
angle_plate : 50 degree
sdr : 26
dp:
L : {{ function(S_plate) }}
W : {{ W_chan }}
OD_ent_pipe : {{ OD_ent_pipe }} # user input
OD_drain : {{ OD_drain }}
num_plates : {{ num_plates }}
L_plate : {{ L_plate }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment