Solve for value using grasshopper


I’ll get straight into my question. Basically I have a ship hull (closed brep) that i have to calculate some stability stuff for (specifics not too important). To do this i have the ship hull itself and a cutting plane. The ship’s hull is rotated, and then the cutting plane cuts the hull shape, so that i only calculate the volume under the waterline.

The problem comes from the fact that the volume has to stay constant regardless of the rotation of the ship. I already have found a way to move the cutting plane (waterline) up and down. I however don’t have a way to find the correct height so that the underwater volume stays the same as in the upright situation.

I was trying to look for a solver that will solve for a certain input value to obtain the correct volume, but i haven’t found anything. I have also tried to make some scripts with grasshopper python with no success.

Hopefully someone has a way of solving this. Any help is greatly appreciated!

The ‘Z-offset Solver’ in my hydro model does exactly that using a pair of Anemone loops (nested) to move the hull(s) up and down to find the target volume (displacement). But it takes some time and effort, it’s not “real time” feedback as you adjust pitch and roll.

The GH code is very old now and probably needs a revisit but it’s rather complicated. It handles multihulls and the “leeward pod” shown above that touches water only when the boat is heeled - like the “safety ama” on Hawaiian sailing canoes.

The ‘Domain Search Solver’ is a subset of the ‘Z-offset Solver’ and can be adapted to solve similar goal seeking issues unrelated to volume. It systematically adjusts one value until the ‘Feedback’ value is as close to zero as possible.

P.S. With some additional GH and GIMP/Javascript I used that ‘Z-offset Solver’ to create this interactive visualization of how COB moves fore and aft as pitch goes from 4 to -4 degrees:

Thank you! This is just the thing i am lookin for. Its getting quite late so ill take a look in the morning, but thanks for your fast reply.