Polymer generation with Gillespie algorithm