Coder Social home page Coder Social logo

requirements_for_self-organization_video's People

Contributors

francesco215 avatar n-shevko avatar

Stargazers

Wisam Reid avatar

Watchers

Wisam Reid avatar  avatar  avatar

Forkers

wisamreid

requirements_for_self-organization_video's Issues

Snake-ising model

We need an animation that draws lots of circles in a snake pattern like the one of the website

Screenshot 2023-12-13 alle 19 08 32

As usual each node can have two possible values (0 or 1), so they can have two colors WHITE or BLACK, and we also need a function that animates the color changes. Maybe we can just reuse the update_fill function already present in the code

Each circle will be connected by a segment with the color=hamiltonian_color

i'd say that is better to put the code in a separate python file inside the project folder

Tip

In the website code i wrote a function that returns the realtive position in a $i,j$ grid of all the elements in the serpentine, i think translating this in python this will make your job easier.

I don't know how deep i have to go into the explanation of this function, but printing the output a couple of times should be enough. if you need any clarifiaction you can always ask

function Serpentine(i, nSH) {
        //nSH represents the variable numSpinsHorizontal
        if (i<nSH) return [i, 0]
        if (i==nSH) return [nSH-1, 1]
        if (i<=2*nSH) return [2*nSH-i, 2]
        if (i==2*nSH+1) return [0,3]
        
        
        let recursive=Serpentine(i%(2*(nSH+1)),nSH);
        recursive[1]+=4*Math.floor(i/(2*nSH+2));
        
        return recursive
}

square around the circles

Write an function make_square(start:int,end:int,color)

that draws a square of color color encapsulating all the circles from the index start to the index end

the circles are in the "straight formation"
Screenshot 2023-11-27 alle 18 36 46

Chain rolling

Start with the sequence described in #8
Screenshot 2023-11-22 alle 11 19 29

We need a function roll_chain that rolls all the elements of the sequence $s_0, ..., s_N$ into a circle like so
Screenshot 2023-11-22 alle 12 17 27

Plotting a network

Ok i said there could be the need for an extra animation, and there is

We need a function that plots a network with manim called something like plot_network(nodes, edges) and it will show something like this

immagine

The main difference with the image is that the nodes can have two possible values (0 or 1), so they can have two colors WHITE or BLACK, and we also need a function that animates the color changes. Maybe we can just reuse the update_fill function already present in the code

The edges will be an $N\times N$ numpy matrix with values either equal to 0 or 1. If you want to generate one that will make a pretty cool graph use the small_world function

The edges can all have the same color hamiltonian_color

Some extra things

There are several ways to choose the positions of the nodes, the easiest one would be to choose them at random inside the frame.

However there are some ploblems with this method (like nodes overlapping and the entire thing looking very garbled), so there are more advanced tecniques of plotting graphs, so look into those, there should be some premade python function out there

Some links to look into

Manim has a Graph mobject class, might be wise to look into it

Tokenized text into a sequence of circles

You start with a text generated from the tokenize function defined in #7
Screenshot 2023-11-22 alle 11 08 26

then each token is turned into a variable name $s_1,s_2,\dots,s_n$ and put inside a circle with the same color of the token

(something similar to this, but with circles instead of squares and colored)
Screenshot 2023-11-22 alle 11 19 29

animation for chain extention

we need an animation that adds element to the chain of elements below

Screenshot 2023-11-27 alle 18 36 46

and in the end becomes like this
Screenshot 2023-11-27 alle 18 36 14

since at the start the shorter chain already occupies almost the entire screen, as you draw all the other circles it will need to un-zoom the image

Tokenization

General description

write a function tokenization(text) that colors the text
Screenshot 2023-11-22 alle 11 08 26
The way it colors the text is explained in this link

input

For our visualization purpuses the function tokenization takes a list of strings text where each element in the text is a token.

For example in the image above the input text will be ['Many',' words',' map',' to',' one',' token',...]

coloring

there will also be a list of colors that will be used to color the text. The i-th token will be colored with the color colors[i%len(colors)]

output

It will return 2 animations:

  • one that draws the text with no coloring
  • one that colors the text

If you prefer you can make two function (one for each animation)

Highlight attention links

Start with a system as specified in #10
Screenshot 2023-11-22 alle 12 27 49

Write a function that implements an animation that highlight a set of links.
By highighting i mean a combination of this three features:

  • increasing the width and opacity of the links highlited
  • deacreasing the width and opacity of the links not highlighted
  • wiggling the links highlighted (facoltative, it depends if it actually looks good or is necessary)
Screenshot 2023-11-22 alle 15 11 35

the highlited link can be also just one of them, probably one way of doing it would be like defining a function highlight_links(links), and the links variable is a list of tuples like [(1,2),(6,8),(6,1)]. In this particular case the connection between the indices 1 and 2, 6 and 8 and 6 and 1 will be highlited, all the others will be dimmed down

Visualization of the attention mechanism

Start with a system as specified in #9
Screenshot 2023-11-22 alle 12 17 27

Make and animation that draws all the lines connecting each couple of elements.
Screenshot 2023-11-22 alle 12 27 49

each line connecting the node $i$ with the node $j$ will have a value associated to it equal to line[i][j].
The color of each line will be determined by mapping its value with a color map like the ones from matplotlib
Screenshot 2023-11-22 alle 12 31 47

Warning

I'm bringing up matplotlib because i'm not sure if you can use a colormap in manim. I did a quick search but the stuff i found is a bit ambigous...

If you can't use a colormap in manim it means that you probably will have to use matplotlib in all of the other animations related to this one (#7, #8 and #9). Btw, i found a cool tutorial to get started with matplotlib

If you can use a colormap in Manim, great! it means you can do as you please

De-zoom ising 2D

As of now the 2D grid is shaped in such a way that it fits inside the window size.

However, we need an animation that looks at the system from further away

Something similar to this video

Make sure it supports the feature in #2

Problems after zooming out

here in the video i zoom out and then change color of one square, and then draw the boundaries.

Ising_2D.mp4

as you can see the grid['squares'] refer to the squares before doing the zooming out via the function zoom_out

the code is in the spin_grid.py file and goes at follows:

#zooming out
self.play(*zoom_out(grid,scale=.7), run_time=5)
#here the color is changed in the square as if it was never zoomed out
animation=grid['squares'][73].animate.set_color(RED)
self.play(animation)   
#here the boundaries are drawn as if the grid never zoomed out
self.play(*add_boundaries(grid))

2D boundaries drawing animation

In the current representation, the boundary delineating opposing spins in the 2D Ising model is constructed by animating the drawing of individual segments in an independent manner.

Instead of isolating each segment, consider a method where the boundary is drawn by tracing around the collective path formed by opposing spins.

If two domains meet at just one corner split the two domains like in the image below
Screenshot 2023-11-14 alle 11 56 50

a useful example you might want to look at is the one where a point draws a trace

Add demarcation line between neighboring spins

In the spin grid, when it looks like in the image below
Screenshot 2023-11-06 alle 12 23 51

i would like to have a function that returns an animation that draws the boundary between the white squares and the black squares

Fully connected ising model

This is the system i'm talking about
Screenshot 2023-11-06 alle 12 01 18

Basically you have to make an animation for drawing this system, and also a way of drawing the lines connecting the circles.

Similar to how you did in the spin_grid.py file, we need some functions to draw, animate and update the values of the spins

Chain Unrolling

Not sure if this is needed as a separate issue...

Anyway, the idea is to do the reverse animation of #9

arrows for the chain

we need a function draw_arrows_for_chain() that returns an animation that draws arrows connecting different circles

IMG_035303ED9277-1

some details

the function draw_arrows_for_chain(links) has as argument links that is an array that specifies where the arrow start from and where they go (similar to how you did the functions that connect the circles for the animation below)

asd.mp4

make sure it's compatible with the code for issue #13

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.