Say an open fridge door loses 1 Joule's worth of cool air every second. Opening or closing the door blows a lot of air so you lose 10J.
If I'm just pouring milk in my coffee I can usually do that in 5 seconds so I should keep the fridge open because 10+5+10 < 10+1+10 + 10+1+10 (if it takes 1 second to get milk).
If I am making a sandwich then I should definitely grab everything (12 seconds), close the door, make a sandwich (3 minutes), then put everything back because 10+12+10 + 10+12+10 < 10 + 180 + 10.
Say it takes seconds to grab or return something and seconds to grab it and use it and return it. Then we should close the fridge if .
What if I'm not sure how long something will take?
Suppose the time to pour my coffee is drawn from a nearly normal distribution with mean 8 seconds and s.d. 2 seconds. I'm better off on average leaving the door open. Even if it's already been 10 seconds, I expect to be done very soon. So I should always leave the door open.
(Scaled) geometric distribution: Half the time, when I would be done, another thing comes up (milk is sealed, spoon not in drawer) that takes another 4 seconds. I always expect to be done 8 seconds later, so I should still always keep the door open I think.
What if I have no idea how long something will take? The door is open and I'm waiting and waiting for the toddler to give back the iced mocha latte and it's sure been a while. Must I take some prior? Is there a mystery here or is this just standard bayesian stuff?
Something that may help build a better model/intuition is this video from Technology Connections: https://www.youtube.com/watch?v=CGAhWgkKlHI
I mentally visualize the cold air as a liquid when I open the door, or maybe picturing it looking similar to the fog from dry ice.
Since it's cold, it falls downward, "pouring" out onto the floor, and probably does not take more than a few seconds, though I would love to see someone capture it on video with a thermal camera.
After that, I figure it doesn't really matter how long the door is open, until you start talking about leaving it open for 10+ minutes where you can then start to worry about the food's temperature rising, and the fridge wasting energy trying to cool the open space.
On the timescale of just a few moments while you grab stuff, the damage is already done once you open it the first time, and leaving it open or opening/closing it again doesn't really affect anything.
This is also why grocery stores and restaurant kitchens tend to have reach-in fridges, open from the top like a chest freezer, instead of vertical doors (though, that's also for convenience).