Giter VIP home page Giter VIP logo

kirigami_sim's Introduction

2D Kirigami Deployment Simulator

This code simulates the 2D deployment process of a kirigami pattern given its tile geometry and connectivity. The code is written in Python using the 2D rigid body physics library Pymunk.

Any comments and suggestions are welcome.

If you use this code in your own work, please cite the following paper:

L. Liu, G. P. T. Choi, and L. Mahadevan, "Quasicrystal kirigami." Physical Review Research, 4(3), 033114, 2022.

============================================================

A set of deployable quasicrystal patterns (a variety of 5-fold Penrose, 8-fold Ammann-Beenker, 12-fold Stampfli patterns of different sizes) have been included as examples in the info_files folder.

Usage:

Run "run_simulation.py" after setting the desired vertices, constraints, and hull files via command-line arguments.

Run example for Penrose pattern deployed using the expansion tile method:

python run_simulation.py --vertices_file info_files/penrose110_vertices.txt --constraints_file info_files/penrose110_expansion_constraints.txt --hull_vertices_file info_files/penrose110_expansion_hull.txt --is_interactive true --calculate_area_perim true --auto_expand true

More file pairing examples:

Penrose expansion, 5-layer pattern

  • vertices_file: penrose110_vertices.txt,
  • constraints_file: penrose110_expansion_constraints.txt,
  • hull_vertices_file: penrose110_expansion_hull.txt

Penrose Hamiltonian, 5-layer pattern

  • vertices_file: penrose110_vertices.txt,
  • constraints_file: penrose110_hamiltonian_constraints.txt,
  • hull_vertices_file: penrose110_hamiltonian_hull.txt

Penrose removal, 5-layer pattern

  • vertices_file: penrose110_nothinrhombs_vertices.txt,
  • constraints_file: penrose110_nothinrhombs_constraints1.txt,
  • hull_vertices_file: penrose110_nothinrhombs_hull1.txt

============================================================

The simulation runs using data on a pattern's vertices, constraints, and hull.

The vertices file specifies the coordinates of each tile's vertices. Row i contains the vertex coordinates for tile i and should be formatted (with vertices v in clockwise order) as

[v1-x-coord | v1-y-coord | v2-x-coord | v2-y-coord | v3-x-coord .... ].

An example showing how tiles were entered for the Penrose pattern is shown below. Tiles are numbered in order, and each tile's Vertex 1 is marked in red.

In the constraints file, order of rows doesn't matter and each row takes the form

[Tile i | Vertex Number p in Tile i | Tile j | Vertex Number q in Tile j].

A pinjoint is made fixing the distance between vertex p of tile i and vertex q of tile j to be the same distance apart as they are in the contracted pattern state. For example, a row [1 3 2 1] would constrain Tile 1's third vertex and Tile 2's first vertex to be a fixed distance apart. If the two vertices were already in the same position, they will be "connected" and fixed to have the same position. Ideal expansion tiles were produced by constraining two vertices that were at opposite ends of an edge, which fixes the vertices to be one edge-length apart.

A hull vertices file specifies which vertices make up the outer hull of the pattern, in clockwise order. It is needed only for calculating the area and simulating deployment with radial springs pulling outward. Each row takes the form [Tile i | Vertex p] to denote that tile i's pth vertex is a point on the pattern's hull. The --hull_vertices_file and --hull_tiles_file arguments are different. Files with names ending in hull_tiles only include the tiles (not the specific vertices) of the hull, and need to be used with the --hull_tiles_file argument instead.

============================================================

Additional notes:

  • All command-line arguments can be found in the parse_args function in utils.
  • The --display_size, --x_offset, --y_ofset, and --vertex_multiplier arguments can be used to adjust the scale and view of the expanding pattern; different patterns will be best viewed with different values for these.
  • When --is_interactive is true, users can click and drag to interact with tiles, right click to pin tiles, press p to save a screenshot of the simulation, press r to reset the simulation, and press v or c to save a file with the current tile vertex/center locations.
  • To use the simulation without a hull file, set --auto_expand and --calculate_area_perim to false.
  • Use --display_expansion_springs to toggle whether or not to display the springs used for automatic deployment.
  • Physical properties like friction, damping, spring strength, and so on can be set via Pymunk. Pymunk's documentation is a great resource for this.
  • There are compatibility issues between certain versions of Python and Pygame. This may be a reason why the simulation is not working.
  • The animations above are produced using data from the simulation, plus additional processing to assign colors, etc.

kirigami_sim's People

Contributors

lliu12 avatar garyptchoi avatar

Stargazers

Yayati Jadhav avatar  avatar Takahiro Misawa avatar  avatar  avatar Reed avatar  avatar

Watchers

 avatar

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.