How is grit and flow calculated?

What are the variables that go into the grit and flow calculations? How can I improve my flow?