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
        c               % Configuration file for running the model
        layout          % Farm layout
        mesh            % Mesh of points to perform flow calculations on
    end

Protected Properties

These properties are for internal use only

    properties (GetAccess = protected)
        powerCalculator % Calculator that determines power from flowfield
        power           % Vector for power values of multiple simulations
        powerParameter  % Vector for parameters regarding the power values
    end

Public Methods

These methods can be called externally from the main file

    methods

Constructor

This constructor loads all public properties, to make sure that the model can be run without any customization. However, all properties are set to default objects, which only contain dummie values.

        function M = Model()
            M.c                 = DefaultConfig(10, 0);
            M.turbineType       = DefaultTurbineType();
            M.layout            = DefaultLayout(M.turbineType);
            M.mesh              = M.layout.getMesh();
            M.wakeModel         = JensenWakeModel();
            M.powerCalculator   = PowerCalculator(M);

            % The timer is started for the method |Model.getElapsedTime()|
            tic;
        end
ans = 

  Model with properties:

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

Evaluate Model

This method is the most imporant handle to evaluate the model. It can be used by GUIs or manually. Another method is available to evaluate the model with a new configuration. This might be usefull when studying a parameter sweep.

        function M = evaluate(M)
            M.wakeModel.calculateFlowField(M);
        end

This method simply sets the given Config object and calls the method Model.evaluate().

        function M = evaluateWithConfig(M, config)
            M.c = config;
            M.evaluate();
        end

        function P = getPower(M)
            P = M.powerCalculator.calculatePower();
        end


        function time = getElapsedTime(M)
            time = toc;
        end

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

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

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

        function M = plotPower(M, p)
            P    = sum(M.powerCalculator.calculatePower() / 10^6);
            M.powerParameter = [M.powerParameter p];
            M.power = [M.power P];

            [M.powerParameter, s] = sort(M.powerParameter);
            M.power = M.power(s);

            plot(M.powerParameter, M.power, 'x-');
        end
    end
end