Skip to content

[Developer Issue] Simulation initialization fails w/ subfunction calls #876

@dforbush2

Description

@dforbush2

Project
Associated with In Progress/Wave Phase correction w/ mean translation

Describe the issue
W/ in simulink, to facilitate changes and version tracking, matlab function blocks have syntax like so:

function [outputs]= functionName(inputs);
% initialize outputs
outputs = 0;
% call to external *m function file functionName.m
[outputs]= functionName(inputs);
end

When developing this feature, I have a feedback loop output-to-input broken w/ a memory block to keep track of the position of the last wave phase adjustment.

If I maintain our standard syntax as above, the simulation fails to initialize b/c it does not know how to size dispLast, and it "is inferred as a variable-size parameter". (Designating it as variable-size causes other problems, and, because it will be the same size w/in a simulation, shouldn't be necessary). What is odd is that an equivalent structure is used in the yaw excitation blocks and seems to work fine. The only exception is that the source of the pass-through variable in that case is a constant and not an in-port.

If, however, include the *m file directly in the matlab function block (as opposed to referencing the external .m), the simulation runs correctly. Because one of these blocks exists in every version of the wave excitation block (8-ish in total), this is NOT the preferred development pathway, but I can't figure out how to get it functional w/ in our preferred syntax with an external *m file.

Open to any advice on this. I will also initiate a pull request for anyone developer interested in playing w/ this. Issue will be closed when resolved satisfactorily in the pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Libraryupdates to the WEC-Sim LibrarySCMsource code mangagement and warnings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions