Adding a new VBR core method
To add a new method to the VBR core:
- Open the corresponding parameter file in
vbr/vbrCore/paramsand then:- add the new method name to the
params.possible_methodscell array - add an
elseifcatch for the new method name - within the
elseif, setparam.func_nameto the name of the matlab function that you will write for the new method, e.g.,param.func_name='new_vbr_method' - set any other values/parameters that the new method needs.
- add the new method name to the
-
Create a new file in
vbr/vbrCore/functionsfor your new function with the name fromparam.func_name. Using the above example, that would benew_vbr_method.m. - Write your new method function. The function must have the
VBRstruct as input and output:function [VBR] = new_vbr_method(VBR)The remainder of the function is where you write whatever calculations are appropriate. The VBR structure will come in with all the state variables and parameter values. State variables are accessed with, e.g.,
VBR.in.SV.TorVBR.in.SV.phi. The parameter values are accessed withVBR.in.method_type.method_namewheremethod_typeis the same as the parameter file that you modified (anelastic,elasticorviscous) andmethod_nameis the name you added toparams.possible_methods. -
To return the results of your function, modify the
VBR.outstructure appropriately, e.g.,VBR.out.method_type.method_name.result = result;wheremethod_typeis the same as the parameter file that you modified (anelastic,elasticorviscous) andmethod_nameis the name you added toparams.possible_methods - If your new method relies on other methods (e.g., you’re putting in a new anelastic method that requires an elastic method to exist), you can add your method to
vbr/vbrCore/functions/checkInput.mfollowing the other methods already there.
To use your new method, simply add the new method name to the methods_list, before you call VBRspine, e.g.:
VBR.in.method_type.methods_list={'method_name'}
where method_type is anelastic,elastic or viscous and method_name is your new method.