Hi there,
I’m trying to implement a spring to the sliding axis of the foil, by getting the foil forces into the boat.port section of V001.bic. My idea was to then do something like: foilext = full extension – lifting force_z / stiffness. Is that possible at all?
Regards, Albert
To get the maximum extension, you can use the custom FoilExtMax block (see full code for this custom block below). The FoilExtMax is simply a BL.State that sets it’s max value to the maximum extension of a given foil (which is not yet know at the time the BOC is parsed).
You will need to use the force at the previous time step using a BL.UnitDelay on the force z, and modify extension at the input of the foil block. The unit delay is needed to break the cycle. Note that this won’t work using solvers (eg. VPP).
Here is an example:
"maxExtension" : BL.FoilExtMax({Foil: "{Foil}",}),
"Stiffness" : 1000000,
"FoilFz" : "{FM}.F()[2]",
"FoilFz_prev" : BL.UnitDelay({ Src:"{FoilFz}" }),
"FoilExt" : "{maxExtension} - {FoilFz_prev} / {Stiffness}",
Also, note that you might want to use a manual extension rather than the maximum extension to not have the stiffness depending on the designed extension. So:
"FoilExt": "{FoilExtManual} + {Fz} / {Stiffness}"
Or if you just have a spring without foil extension:
"FoilExt": "{Fz} / {Stiffness}"
The code defining the FoilExtMax block can be written in a separate FoilExtMax.js file to be added in the “Blocks” folder of your model repository. Add the new file to your model inside the foil *.bic file using:
dofile(spec.boatPath + "Blocks/FoilExtMax.js");
Content of FoilExtMax.js:
// FoilExtMax returns the max extension of a foil
Block.registerNewType("FoilExtMax", function(name, r)
{
var foil = r.Foil;
var maxExtension = 1;
var block = Block.JS(
name,
// Array with input names
[],
// Object of output names and types
function (input) {
return maxExtension
}
);
return {
block: block,
config : {
configureInputs : function()
{
// The configure input is called when all the blocks have been created.
// (We cannot use 'findSourceFromMapping' before all blocks have been created)
// Find foil block to read the max extension
var foilBlock = block.findFromMapping(foil);
if (foilBlock.maxExtension() === undefined) {
throw new Error("Could not initialise max extension of '" + block.name() + "'. '" + foilBlock.name() + "' is not a foil");
}
// Add inline implicit module to set max extension
G.ImplicitModules.push({
init : function() {
maxExtension = foilBlock.maxExtension();
},
});
// return {inputs : r.Inputs};
return r.Inputs;
},
},
};
});
