Model Object

This document contains the Model object, which forms the basis of this code bundle. It prepares the memory of MATLAB taking into account all aspects of the wake model. The turbine characteristics and the wind farm layout are loaded, the wind conditions are set and the calculation mesh is constructed.

It is important to keep the reference to the object in the main memory of MATALB, as you can pass it to several manipulators like a GUI or Plotters.

The most relevant method of this object is Model.evaluate(ConfigInterface), which runs the model with the given configuration object. Before running the model, the following properties can be set. They are, however, always loaded with a default object.

Contents

Create Object

By letting the object subclass the handle object, different manipulators that are being past the same reference of this object will also manipulate the same data.

classdef Model < handle

Public Properties

The following properties can be set by the user from the main file.

    properties
        wakeModel       % Wake model
        turbineType     % Turbine type
        config          % Configuration file for running the model
        layout          % Farm layout
        mesh            % Mesh of points to perform flow calculations on
    end

Protected Properties

    properties (GetAccess = protected)
        timeStart;

        pVec
        PVec
    end

    methods
        function M = Model()
            M.config      = DefaultConfig(10, 0);
            M.turbineType = DefaultTurbineType();
            M.layout      = DefaultLayout(M.turbineType);
            M.mesh        = M.layout.getMesh();

            tic;
        end

        function M = evaluate(M, config)
            M.config = config;

            M.wakeModel = JensenWakeModel(M.config.V0, M.config.alpha, 0.08);
            M.wakeModel.calculateFlowField(M);
        end

        function P = calculatePower(M)
            P = zeros(1, M.layout.N);
            for ii=1:M.layout.N

                P(ii) = M.turbineType.power(M.getTurbineWindSpeed(M.layout.z(ii), M.layout.y(ii)));
            end
        end

        function V0 = getTurbineWindSpeed(M, z0, y0)
            [iiZ, iiY] = M.mesh.find( ...
                z0 - M.turbineType.D / 2 * cos(M.config.alpha), ...
                y0 - M.turbineType.D / 2 * sin(M.config.alpha) ...
            );

            V0 = M.wakeModel.A(iiY, iiZ) * M.config.V0;
        end

        function getElapsedTime(M)
            toc;
        end

        function M = plot(M)
            subplot(121);
            M.plotFlowField();

            subplot(122);
            M.plotPower(M.config.alpha/pi*180);
        end

        function M = plotFlowField(M)
            cla reset
            M.wakeModel.plotFlowField(M);
        end

        function M = plotPower(M, p)
            P    = sum(M.calculatePower() / 10^6);
            M.pVec = [M.pVec p];
            M.PVec = [M.PVec P];

            [M.pVec, s] = sort(M.pVec);
            M.PVec = M.PVec(s);

            plot(M.pVec, M.PVec, 'x-');
        end
    end
ans = 

  Model with properties:

      wakeModel: []
    turbineType: [1x1 DefaultTurbineType]
         config: [1x1 DefaultConfig]
         layout: [1x1 DefaultLayout]
           mesh: [1x1 DefaultMesh]

end