For instance, is it possible to go through all the input parameters of a hull hydrodynamics RANS matrix, set the model in the corresponding state and print the corresponding hydrostatics forces and moments on the hull calculated by Gomboc?
In the GUI Commands Window, the method B(‘YourBlockState’).setValue() enables to put a given block of the model into the specified state, and Z(‘YourOutputChannel’) enables to evaluate a channel. For instance B(‘Boat.Leeway’).setValue(1) will impose a Leeway of 1, and Z(‘Boat.Aero.FM’).toFrame(Z(‘Boat.Frame’)).M[0] will evaluate the aero rolling moment in the boat frame of reference.The B(‘YourBlockState’).setValue() and Z(‘YourOutputChannel’) can easily be built into a loop, or more complex function, to do more complex analysis. For example, the following script is a template to show how to loop through all the rows of a hydro RANS CSV file to read the RANS inputs of each row, put the model in the corresponding state, evaluate and print the Gomboc hull hydrostatics forces and moments:
var lines = filelines(“YourPathToRANSFile.csv”)print(lines[0])for (var i = 1; i < lines.length; i++) {
row = lines[i].split(‘,’)
G.M.runWithAutoUpdateLocked(function() {
B(‘Boat.Optimisation.Speed’).setValue(row[0]);
B(‘Boat.Optimisation.Leeway’).setValue(row[2]);
B(‘Boat.Optimisation.Trim’).setValue(row[3]);
sinkvalue = parseFloat(row[1])+ (11.675-10.36)*sind(Z(‘Boat.Optimisation.Trim’));
B(‘Boat.Optimisation.PortFoilSink’).setValue(sinkvalue);
})
var fm = Z(‘Boat.Port.Hull.FMHydrostatics’);
print(i, fm.F, fm.M);
}
Note 1: B() is an access to the block itself (and you can see all the things you can do with it by query(B(‘YourBlockState’)) and Z(‘YourOutputChannel) is an access to an output channel.
Note 2: Using ` B(‘YourBlockState’).setValue(123)` always updates the model. When changing many states at once in a script, the many model updates can slow down things considerably. Using `runWithAutoUpdateLocked` like in the example above will prevent that (you pass a function that modifies the model and the model will be updated once when the function has executed).’,’Output chosen forces and moments for many different parameter values like the inputs of a RANS matrix.