Git Product home page Git Product logo

topy's Introduction

ToPy

ToPy Logo

ToPy is a lightweight topology optimization framework for Python. It was originally hosted on Google Code, please refer to the ToPy wiki

Installation

All you need is the following:

$ git clone https://github.com/williamhunter/topy
$ cd topy/topy
$ python setup.py install

Initialization

The main class of ToPy is Topology. It definess the main constraints, grid and parameters of optimization. There are 2 ways how you could define the Topology:

  • TPD file. It is usefull for comand line
  • Config dictionary. This is quite close to TPD file. However, it is a way useful if the initialization in code is needed.

TPD (ToPy Definition)

There is a minimal set of parameters, which is required for successful definition of the problem:

PROB_TYPE  : comp 
PROB_NAME  : mbb_beam_minimal
ETA        : 0.5 
DOF_PN     : 2
VOL_FRAC   : 0.5
FILT_RAD   : 1.5
P_FAC      : 3
ELEM_K     : Q4
NUM_ELEM_X : 60
NUM_ELEM_Y : 20
NUM_ELEM_Z : 0
NUM_ITER   : 10 
FXTR_NODE_X: 1|21 
FXTR_NODE_Y: 1281 
LOAD_NODE_Y: 1
LOAD_VALU_Y: -1

You can read more about successful problem definition here.

When the .tpd file is defined, then the rest is simple:

from topy import Topology

topology = Topology()
topology.load_tpd_file('file.tpd')

Config dictionary

First you have to define a config dictionary:

config = {
     'DOF_PN': 2,
     'ELEM_K': 'Q4',
     'ETA': '0.5',
     'FILT_RAD': 1.5,
     'FXTR_NODE_X': range(1, 22),
     'FXTR_NODE_Y': 1281,
     'LOAD_NODE_Y': 1,
     'LOAD_VALU_Y': -1,
     'NUM_ELEM_X': 60,
     'NUM_ELEM_Y': 20,
     'NUM_ELEM_Z': 0,
     'NUM_ITER': 94,
     'PROB_NAME': 'beam_2d_reci',
     'PROB_TYPE': 'comp',
     'P_FAC': 3.0,
     'VOL_FRAC': 0.5
}

The requirements are the same as for .tpd file.

topology = Topology(config=config)

Optimization

You can use one-line solution:

$ python topy/scripts/optimise.py <filename>.tpd

Or with script:

import topy

config = {...}
t = topy.Topology(config)
t.set_top_params()
topy.optimise(t)

Visualization

Module topy.visualization allows one to save the output as a .png image for 2D problems or as a .vtk file for 3D. You can animate the obtained images with convert tool.

convert -delay 35 *.png anim.gif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.