I am quite new with Matlab and especially with OOP in it. I have a question regarding object construction:
to get basic parameters of an object - a journal fluid-film bearing - given initial parameters: geometric, operational and so on.
why am I using OOP: i want to ultimately get a program that could run on any given number of bearings as usually there are at least two of them in one system. creating new instances of the class 'JournalBearing' would allow vibrational analysis of a multi-bearing system.
i want to create an object of the class in question given the initial parameters:
jb1 = JournalBearing(L,R,h0,m,n); <- here L and R are length and radius, h0 - radial clearence (difference between bearing radius and rotor radius, usually a very small value in microns), m and n are mesh parameters: determination of bearing characterisitcs requires solution of a PDE over some m x n mesh.
I guess there should be more parameters in the constructor here to get properties of the object.
I have developed a few methods that help define some of the parameters of the bearing: radial gap function, pressure distribution in the fluid film and some mathematical methods - derivatives along two coordinates. So far I have been able to determine these parameters by means of simply calling the methods:
[h,dhdx] = jb1.RadGap(X0,Y0); <- method returns the radial gap function and its derivative given initial rotor coordinates;
[p]=jb1.PresDis(h,dhdx,n_rpm,mu,Xdot,Ydot,PresCond); <- method returns pressure distribution - an m x n matrix given some operational parameters, initial rotor velocity and pressure conditions around the bearing - we set it to 0 as its ambient pressure all around, although could be different with axial fluid supply.
Now there is my problem: I want only one line instead of these three: I want the line
jb1 = JournalBearing(L,R,h0,m,n, ...../* all other parameters */);
to result in creation of an object jb1 with all the parameters such as radial gap, its derivative, pressure distribution and others as its properties. So, as I would put it, I need the constructor to call the developed methods and assign the output value to the corresponding property.
here is what the class looks like now with the present constructor:
classdef JournalBearing < handle
function thisTarget = JournalBearing(l,R,h0,m,n)
and here is the radial gap function method to assign the output to the property:
function [h,dh] = RadGap(obj,X,Y)
The main question being: is there any reason to divide the code into small methods in order to fill in the properties like that without calling the methods from the main file? I think, theoretically, I could just have one method - constructor - doing all the work and assign results to properties as I get them which would result in merging all methods into one and having tens of input parameters, or could I call methods from the constructor somehow?
I hope it is understandable. Thank you very much for any help, if you have any questions, feel free to ask.