Spray foam is also an insulator. I think that may be a bad thing to encapsulate them in foam. They might overheat. Not good for a battery. I would maybe make some shims out of some other material that doesn't create a completely sealed blanket.
I like your idea mechanically. That space looks about perfect for some 1/2 inch pink closed cell foamboard jammed in around the top. That might give you the same effect without encapsulating it completely. Allowing a little "breathing room".
This is just my opinion. I am not an expert on this topic. However, I do know that you need to use closed cell foam. The open cell (lighter/fluffier stuff) soaks up water.
I like your idea mechanically. That space looks about perfect for some 1/2 inch pink closed cell foamboard jammed in around the top. That might give you the same effect without encapsulating it completely. Allowing a little "breathing room".
This is just my opinion. I am not an expert on this topic. However, I do know that you need to use closed cell foam. The open cell (lighter/fluffier stuff) soaks up water.