From 2ebea14834a6ffdd623a3e8ec2609fd251cf9f8a Mon Sep 17 00:00:00 2001 From: Thomas Lambert <t.lambert@uliege.be> Date: Thu, 25 May 2023 14:01:42 +0200 Subject: [PATCH] feat(Result): introduce result class --- src/classes/@Result/Result.m | 61 ++++++++++++++++++++++++++++++++++++ src/rotare.m | 14 ++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 src/classes/@Result/Result.m diff --git a/src/classes/@Result/Result.m b/src/classes/@Result/Result.m new file mode 100644 index 0000000..f24772c --- /dev/null +++ b/src/classes/@Result/Result.m @@ -0,0 +1,61 @@ +classdef Result < handle + % RESULT Result obtained from a simulation with Rotare. + % This class defines the Result object that can be used to store the solution an entire Rotare + % simulation. + % + % Notes: + % - Almost all properties are private to prevent accidental overwriting. + % + % ----- + % + % Result properties: + % leishman - Results obtained with the leishman solver + % indfact - Results obtained with the indFact solver + % indvel - Results obtained with the indVel solver + % stahlhut - Results obtained with the stalhlut solver + % operPts - Table with the operating points for each individual result + % + % + % Result methods: + % + % Result constructor: + % Result = Result() creates an empty object. + % + % Constructor inputs: + % + % See also: Rotor, rotare, template, af_tools.Airfoil. + % + % <a href="https:/gitlab.uliege.be/rotare/documentation">Complete documentation (online)</a> + + % ---------------------------------------------------------------------------------------------- + % FIXME: Make plot methods to compare two results easily + % ---------------------------------------------------------------------------------------------- + % (c) Copyright 2022-2023 University of Liege + % Author: Thomas Lambert <t.lambert@uliege.be> + % ULiege - Aeroelasticity and Experimental Aerodynamics + % MIT License + % Repo: https://gitlab.uliege.be/rotare/rotare + % Docs: https://gitlab.uliege.be/rotare/documentation + % Issues: https://gitlab.uliege.be/rotare/rotare/-/issues + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + % Base properties of the elements + properties + leishman (1, :) OperRotor % Results obtained with the leishman solver + indfact (1, :) OperRotor % Results obtained with the indFact solver + indvel (1, :) OperRotor % Results obtained with the indVel solver + stahlhut (1, :) OperRotor % Results obtained with the stalhlut solver + operPts (:, 4) table % Table of operating points for each individual result + end + + methods + + function self = Result() + % Result Constructor. + % Creates the Result object. + % + % Currently empty on purpose. Results are to be assigned manually. + end + + end +end diff --git a/src/rotare.m b/src/rotare.m index c578420..969e442 100644 --- a/src/rotare.m +++ b/src/rotare.m @@ -1,4 +1,4 @@ -function [OpRot] = rotare(configFile) +function [Results] = rotare(configFile) % ROTARE A feature-rich and open source implementation of the BEMT. % This code is an implementation of the Blade Element Momentum Theory (BEMT) used for the % analysis of all all kinds of rotors. @@ -58,6 +58,9 @@ function [OpRot] = rotare(configFile) % Import packages import af_tools.* + % Init the output object + Results = Result(); + % ============================================================================================== % ==================================== Pre-processing ========================================== % ============================================================================================== @@ -132,6 +135,10 @@ function [OpRot] = rotare(configFile) % Keep track of CPU time for the solution OpRot(iOperPoint, i).cpuTime = toc(tStart); + % Table that identifies the operating point for future reuse + operPoints(iOperPoint, :) = [Uop.altitude(iAlt), Uop.speed(iSpeed), ... + Uop.rpm(i, iRpm), Uop.collective(i, iColl)]; + iOperPoint = iOperPoint + 1; end @@ -143,6 +150,11 @@ function [OpRot] = rotare(configFile) disp(' '); end + % Output result in an easily accessible form + Results.(Mod.solver) = OpRot; + Results.operPts = array2table(operPoints, ... + 'VariableNames', {'Alt', 'V_ax', 'RPM', 'Coll'}); + % Save solution to MAT-file for future reusability if Sim.Save.autosave TmpStruct.OpRot = OpRot; -- GitLab