예제 #1
0
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Simple pipe reflected.')
command_line_parser.parse()

from schematics import Point
from schematics import Canvas
from schematics import Pipe
from schematics import Component

CAN = Canvas(border_thickness = 0.05, grid = True)

print(Component.stats)

CAN.add_component( Pipe(5, 1.0, Point(0.0, 0.0) , label_location = 'center', label_pad = 1.0, name = 'Not reflected', angle = 0.0, label_angle = 0.0) )

CAN.add_component( Pipe(5, 1.0, Point(0.0, 0.0) , label_location = 'bottom', label_pad = 1.0, name = 'Bottom label \n relfect_x', angle = 0.0, label_angle = 0.0, reflect = 'x') )

CAN.add_component( Pipe(5, 1.0, Point(0.0, -2.0) , label_location = 'center', label_pad = 1.0, name = 'Not reflected', angle = 0.0, label_angle = 0.0) )

CAN.add_component( Pipe(5, 1.0, Point(0.0, -2.0) , label_location = 'top', label_pad = 1.0, name = 'Top label \n relfect_x', angle = 0.0, label_angle = 0.0, reflect = 'x') )

print(Component.stats)

CAN.draw(save_file = 'test.pdf', display = True, print_information = False)
예제 #2
0
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Pentagon graph test case.')
command_line_parser.add_argument('-dir', default = '.', help='directory to be run')
args = command_line_parser.parse()

from subprocess import check_output
from subprocess import call
from os import chdir, getcwd

def run_all(prefix = ''):
  files = check_output(['ls']).splitlines()
  if __file__ in files:
    files.remove(__file__)

  for file in files:
    if file[-3:] == '.py':
      if prefix == '':
        print '\nprocessing...', file
      else:
        print '\nprocessing...', prefix + '/' + file
      call(['python', file])

    elif file[-4:] != '.pdf':
      original_dir = getcwd()
      chdir(file)
      prefix = prefix + '/' + file
      run_all(prefix)
      chop_length = -1 * (len(file) + 1)
      prefix = prefix[:chop_length]
      chdir(original_dir)
예제 #3
0
from __future__ import print_function
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Reflected graph test case.')
command_line_parser.parse()

from schematics import Graph
from schematics import Canvas
import matplotlib.pyplot as plt
from math import sqrt

main = Graph(name='main')

main.add_node(x=0.0, y=0.0, name='A', ll='bottom')
main.add_node(x=1.0, y=0.0, name='B', ll='right')
main.add_node(x=1.0, y=1.0, name='C', ll='top')
main.add_node(x=0.0, y=1.0, name='D', ll='left')

main.connect('A', 'B', name='1', ll='top', la=45.0, lp=1.0)
main.connect('B', 'C', name='2', ll='top', la=45.0, lp=1.0)
main.connect('C', 'D', name='3', ll='top', la=45.0, lp=1.0)
main.connect('D', 'A', name='4', ll='top', la=45.0, lp=1.0)

main.anchor_graph()
print('Nodes are anchored:', main.anchored)
print(main.general_info(), '\n')
print(main)

graphs = []
graphs.append(main)

graphs.append(main.copy(-1.0, 0.0))
예제 #4
0
from __future__ import print_function
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Pentagon graph test case.')
command_line_parser.parse()

from schematics import Graph
from schematics import Canvas

GRAPH = Graph(name='pentagon')

# Add Nodes
GRAPH.add_node(x=0.0, y=0.0, name='A', anchor=True, ll='top')
GRAPH.add_node(x=0.75, y=-1.5, name='B', ll='bottom')
GRAPH.add_node(x=-1.5, y=-0.75, name='C', ll='left')
GRAPH.add_node(x=1.5, y=-0.75, name='D', ll='right')
GRAPH.add_node(x=-0.75, y=-1.5, name='E', ll='bottom')

# Add Connections
GRAPH.connect('A', 'B', name="I", directional=False, ll='top')
GRAPH.connect('C', 'A', name="II", ll='top')
GRAPH.connect('A', 'D', name="III", ll='top')
GRAPH.connect('A', 'E', name="IV", directional=False, ll='top')

GRAPH.connect('B', 'C', name="V", directional=False, ll='top')
GRAPH.connect('D', 'B', name="VI", ll='bottom')
GRAPH.connect('B', 'E', name="VII", ll='bottom')

GRAPH.connect('C', 'D', name="VIII", directional=False, ll='top')
GRAPH.connect('E', 'C', name="IX", ll='bottom')

GRAPH.connect('D', 'E', name="X", directional=False, ll='top')
예제 #5
0
파일: pipe.py 프로젝트: idaholab/schematics
from __future__ import print_function
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Simple Pipe.')
command_line_parser.parse()

from schematics import Point
from schematics import Canvas
from schematics import Pipe
from schematics import Component

CAN = Canvas(border_thickness=0.05, grid=True)

print(Component.stats)

CAN.add_component(
    Pipe(0.75,
         0.3,
         Point(1.0, 1.0),
         name='Component',
         a=0.0,
         ll='bottom',
         lp=1.0,
         la=0.0,
         fs=10))

# CAN.add_component( Pipe(0.75, 0.3, Point(-1.0, -1.0), name = '-90 degrees', a = -90.0,
#                         ll = 'top', lp = 1.0, la = 0.0
#                        )
#                  )
#
# CAN.add_component( Pipe(0.75, 0.3, Point(0.0, -1.0), name = '-45 degrees', a = -45.0,
예제 #6
0
from __future__ import print_function
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Simple core channel.')
command_line_parser.parse()

from schematics import Point
from schematics import Canvas
from schematics import CoreChannel
from schematics import Component

CAN = Canvas(border_thickness=0.05, grid=False)

print(Component.stats)

CAN.add_component(
    CoreChannel(1.0,
                3.0,
                Point(-3.0, 0.0),
                label_location='left',
                name='left \nreflect_y',
                label_pad=0.25,
                angle=0.0,
                reflect='y',
                face_color=(0.6875, .1953, 0.1875, 1.0)))
CAN.add_component(
    CoreChannel(1.0,
                3.0,
                Point(0.0, 0.0),
                label_location='center',
                name='center',
                label_pad=0.25,
예제 #7
0
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Shifting edge label.')
command_line_parser.parse()

from schematics import Graph
from schematics import Canvas
import matplotlib.pyplot as plt
from math import sqrt

main = Graph(name='main')

main.add_node(x=0.0, y=0.0, name='A', ll='bottom')
main.add_node(x=1.0, y=0.0, name='B', ll='right')

main.connect('A', 'B', name='1', ll='top', la=0.0, label_shift=0.75)

graphs = []
displacement = 3.0

for i in range(2):
    graphs.append(main.copy(i * displacement, 0.0))
    graphs[-1].rotate(i * 45.0)

main.connect('A', 'B', name='1', ll='bottom', la=0.0, label_shift=-0.75)
for i in range(2):
    graphs.append(main.copy(i * displacement, 2.0))
    graphs[-1].rotate(i * 45.0)

CAN = Canvas(border_thickness=0.05, grid=True)
for graph in graphs:
    CAN.add_graph(graph)
예제 #8
0
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Detailed node label.')
command_line_parser.parse()

from schematics import Graph
from schematics import Canvas
import matplotlib.pyplot as plt

main = Graph(name='main')

main.add_node(x=0.0, y=0.0, name='test0', ll='bottom', lp=0.0)
main.add_node(x=0.0, y=0.0, name='test1', ll='top', lp=0.0)
main.add_node(x=0.0, y=0.0, name='test2', ll='left', lp=0.0)
main.add_node(x=0.0, y=0.0, name='test3', ll='right', lp=0.0)

bounding = Graph(name='bounding')

disp = 0.1
bounding.add_node(x=disp, y=0.0, name='top', dl=False)
bounding.add_node(x=-disp, y=0.0, name='bottom', dl=False)
bounding.add_node(x=0.0, y=-disp, name='left', dl=False)
bounding.add_node(x=0.0, y=disp, name='right', dl=False)

GRAPH = Graph(name='graph', graphs=[main, bounding])

CAN = Canvas(border_thickness=0.0, grid=True)
CAN.add_graph(GRAPH)

CAN.draw(save_file='test.pdf', display=True, print_information=False)
예제 #9
0
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Compounded graph test case.')
command_line_parser.parse()

from schematics import Graph
from schematics import Canvas


# ------------- pipe1

pipe1 = Graph(name = 'pipe1')

pipe1.add_node(x=0.0, y=0.0, name = 'inlet')
pipe1.add_node(1.0, 0.0, name = 'outlet')

# pipe1.connect('inlet', 'outlet', name = 'internal', directional = False)

pipe1.anchor = 'inlet'


# ------------- pipe2

pipe2 = pipe1.copy(x=1.5, y=0.0, name = 'pipe2')

pipe2.anchor = 'inlet'


# ------------- long_pipe1

long_pipe1 = Graph(name = 'long_pipe1', graphs = [pipe1, pipe2])
예제 #10
0
from __future__ import print_function
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Labeled node test case.')
command_line_parser.parse()

from schematics import Graph
from schematics import Canvas
import matplotlib.pyplot as plt

main = Graph(name='main')

main.add_node(x=0.0, y=0.0, ll='bottom')
main.add_node(x=1.0, y=0.0, ll='right')
main.add_node(x=1.0, y=1.0, ll='top')
main.add_node(x=0.0, y=1.0, ll='left')

main.connect('Node 0', 'Node 1', label_location='bottom', label_angle=30.0)
main.connect('Node 1', 'Node 2', label_location='top', label_angle=30.0)
main.connect('Node 2', 'Node 3', label_location='top', label_angle=30.0)
main.connect('Node 3', 'Node 0', label_location='top', label_angle=30.0)

print(main.edges)

GRAPH = Graph(name='graph',
              graphs=[main],
              node_line_width=2.0,
              node_radius=0.05)
GRAPH.anchor_graph()
print('Nodes are anchored:', GRAPH.anchored)
print(GRAPH.general_info(), '\n')
print(GRAPH)
예제 #11
0
from __future__ import print_function
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Labeled edge.')
command_line_parser.parse()

from schematics import Graph
from schematics import Canvas
import matplotlib.pyplot as plt
from math import sqrt

main = Graph(name = 'main')

main.add_node(x=0.0,   y=0.0,   name = 'A',   ll = 'bottom')
main.add_node(x=1.0,   y=0.0,   name = 'B',   ll = 'right')
main.add_node(x=1.0,   y=1.0,   name = 'C',   ll = 'top')
main.add_node(x=0.0,   y=1.0,   name = 'D',   ll = 'left')

main.connect('A', 'B', name = '1', ll = 'top', la = 0.0)
main.connect('B', 'C', name = '2', ll = 'top', la = 0.0)
main.connect('C', 'D', name = '3', ll = 'top', la = 0.0)
main.connect('D', 'A', name = '4', ll = 'top', la = 0.0)

main.anchor_graph()
print('Nodes are anchored:', main.anchored)
print(main.general_info(), '\n')
print(main)

graphs = []
displacement = 3.0

for i in range(2):
예제 #12
0
from __future__ import print_function
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Simple steam dome reflected.')
command_line_parser.parse()

from schematics import Point
from schematics import Canvas
from schematics import SteamDome
from schematics import Component

CAN = Canvas(border_thickness=0.05, grid=True)

print(Component.stats)

CAN.add_component(
    SteamDome(1.0,
              Point(1.0, 0.0),
              label_location='center',
              name='not reflected',
              label_pad=0.5,
              angle=0.0))
CAN.add_component(
    SteamDome(1.0,
              Point(1.0, 0.5),
              label_location='right',
              name='relfect_y \nright label',
              label_pad=0.5,
              angle=0.0,
              reflect='y'))
CAN.add_component(
    SteamDome(1.0,
예제 #13
0
from __future__ import print_function

from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Pentagon graph test case.')
command_line_parser.add_argument('-dir',
                                 default='.',
                                 help='directory to be run')
args = command_line_parser.parse()

import sys
from subprocess import call
from os import chdir, getcwd, listdir
from os.path import join


def run_all(prefix=''):
    path = getcwd()
    files = listdir(path)
    if __file__ in files:
        files.remove(__file__)

    # remove files
    remove_files = []
    for file in files:
        if file[0] == '.':
            remove_files.append(file)
    for file in remove_files:
        files.remove(file)

    for file in files:
        if file[-3:] == '.py':
예제 #14
0
from __future__ import print_function
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Display color palettes.')
command_line_parser.parse()

from schematics import Point
from schematics import Canvas
from schematics import Pipe
from schematics import Component

CAN = Canvas(border_thickness=0.05, grid=False)

print(Component.stats)
# Reds
CAN.add_component(
    Pipe(1.0, 1.0, Point(-3.0, 3.0), face_color=(0.597659, 0.0, 0.0)))
CAN.add_component(
    Pipe(1.0, 1.0, Point(-1.5, 3.0), face_color=(0.67578, 0.19531, 0.19531)))
CAN.add_component(
    Pipe(1.0, 1.0, Point(0.0, 3.0), face_color=(0.71484, 0.2968, 0.2968)))
CAN.add_component(
    Pipe(1.0, 1.0, Point(1.5, 3.0), face_color=(0.7539, 0.3984, 0.3984)))
CAN.add_component(
    Pipe(1.0, 1.0, Point(3.0, 3.0), face_color=(0.796875, 0.49609, 0.49609)))
CAN.add_component(
    Pipe(1.0, 1.0, Point(4.5, 3.0), face_color=(0.8359, 0.5976, 0.5976)))

# Oranges
CAN.add_component(
    Pipe(1.0, 1.0, Point(-3.0, 1.5), face_color=(0.82, 0.36, 0.01)))
CAN.add_component(
예제 #15
0
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('A long junction.')
command_line_parser.parse()

from schematics import Graph
from schematics import Canvas
import matplotlib.pyplot as plt
from math import sqrt

component1 = Graph(name='component1')
component1.add_node(x=0.0, y=0.0, name='outlet', ll='bottom')

component2 = Graph(name='component2')
component2.add_node(x=2.0, y=1.0, name='inlet', ll='top')

junction = Graph(name='junction')
junction.add_node(x=1.0, y=0.0, name='node1', ll='bottom', draw=False)
junction.add_node(x=1.0, y=1.0, name='node2', ll='top', draw=False)

system1 = Graph(name='system1', graphs=[component1, component2, junction])
system1.connect('component1:outlet',
                'junction:node1',
                dir=False,
                ll='top',
                ew=0.05)
system1.connect('junction:node1',
                'junction:node2',
                dir=False,
                ll='top',
                ew=0.05)
system1.connect('junction:node2',
예제 #16
0
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('A simple system.')
command_line_parser.parse()

from schematics import Canvas
from schematics import System
from schematics import Pipe
from schematics import Point

simple = System('simple')

simple.add_component(
  Pipe(
    1.0, 0.5, Point(), name = 'Pipe 1', angle = 0.0,
    label_location = 'center', label_pad = 0.0, label_angle = 0.0
  )
)

simple.add_component(
  Pipe(
    1.0, 0.5, Point(2.0, 1.0), name = 'Pipe 2', angle = 0.0,
    label_location = 'center', label_pad = 0.0, label_angle = 0.0
  )
)

simple.add_component(
  Pipe(
    1.0, 0.5, Point(4.0, 0.0), name = 'Pipe 3', angle = 0.0,
    label_location = 'center', label_pad = 0.0, label_angle = 0.0
  )
)
예제 #17
0
from __future__ import print_function
from schematics import ExampleDebugger
command_line_parser = ExampleDebugger('Reflected node labels.')
command_line_parser.parse()

from schematics import Graph
from schematics import Canvas
import matplotlib.pyplot as plt

main = Graph(name='main')

main.add_node(x=0.0, y=0.0, name='A', ll='bottom')
main.add_node(x=1.0, y=0.0, name='B', ll='right')
main.add_node(x=1.0, y=1.0, name='C', ll='top')
main.add_node(x=0.0, y=1.0, name='D', ll='left')

# BOTTOM
bottom = Graph(name='bottom')

bottom.add_node(x=0.5, y=-1.0, name='angled name [x]', ll='bottom', la=45.0)

bottom.add_node(x=0.5,
                y=-1.0,
                name='angled (ref) [x]',
                ll='bottom',
                la=45.0,
                ref='x')

bottom.add_node(x=0.5, y=-2.0, name='angled name [y]', ll='bottom', la=45.0)

bottom.add_node(x=0.5,