-
Notifications
You must be signed in to change notification settings - Fork 184
Description
Note: italicized text below is include as an example and should be updated before submission. If you feel any section is not applicable to your request, please replace with 'N/A' rather than delete a section.
Cite the WEC-Sim applications case in question
PTO-Sim
Describe the bug or issue
So what I'm trying to do is pretty simple, I want to define a function, that gets some input values (of the HPTO) and give the wecSim run outputs as outputs (values like piston pressure & ...), but when I do this Matlab gives an error Unrecognized field name "pistonNCF".
It seems when I try to run wecSim with ptoSim using a function, then it doesn't recognize the ptoSim parameters and it treats it like a normal wecSim run.
To Reproduce
- Go to
$WEC-Sim_Applications-master\WEC-Sim_Applications-master\PTO-Sim\RM3\RM3_Hydraulic_PTO directory. - Run
bemio.min the$WEC-Sim_Applications-master\WEC-Sim_Applications-master\PTO-Sim\RM3\hydroData - Alter these lines in
ptoSimInputFile.m:
ptosim.pistonNCF.topA = Ap;
ptosim.pistonNCF.botA = Ap;
- Write the function shown in the Screenshot below.
- type
testFunction (0.18)in the command window.
Expected behavior
I expected this to run smoothly just like when I used a script to do this exact same thing.
Workstation Information (this section MUST BE completed):
- OS: [Windows 7]
- MATLAB/Simulink Release [2021a]
- WEC-Sim Release [v4.2]
Additional context
To give you some more information, when I comment out the 3rd line, the function works perfectly. It seems to me that it can't recognize the ptoSim parameters.
I tried something else, I commented out the 3rd line and tried to assign max(output.ptosim.pistonNCF.topPressure/1e6) to a variable in userDefinedFunctions.m and the same error happened. I wanted to remind you that this exact method works for me when using a Script, but not in a Function.
I ran wecSim with ptoSim using a function and saved the output structure,
then I realized that it does have a ptoSim struct, but it only has the time matrix and nothing else (nothing else was defined).
I think the problem concerns the workspaces of Matlab, the base workspace and the function workspace and the model workspace.
I even tried comparing the model workspaces when using a function running wecSim vs. when using a script, although they were not identical, I still couldn't find anything useful.
