CSC-Soft

   
Software development by order
Software development
Order the software
Requirement specification
Developed software
Ready-made solutions
Visual CSC
Visual Logic
MatBasic
Developers group
Contact us
About the company
Forum
 
News
07.11.2008
The first commercial release of the language of mathematical calculations MatBasic v.1.2

06.11.2007
Release of a new version of mathematical programming environment MatBasic v.1.1

26.08.2007
MatBasic mathematical programming environment beta-version release.

09.06.2007
First official build of CSC-Model module of Visual CSC system for calculating steady and emergency regimes.

12.09.2006
The beginning of development of a logic designing system Visual Logic.

04.08.2006
First release of a universal schematic editor Visual CSC.

    MatBasic


  Introduction     Applications     History     Download     Purchase  

    Examples of MatBasic calculation system application

    MatBasic environment can be used for calculations of a wide range of complexity – from school-level sums to sophisticated science problems solution. This part contains several examples of the environment application.

  1. Example: School-level sum "Snowflake"
  2. Program module of checking an algorithmic metering entry to a set polygonal area
  3. Program module of a frequency determination sensor
  4. Simulation model of a synchronous generator

    Relay protection is purposed for reacting to monitored situations (injuries inside a monitored object) and should be tuned out from alternative states (injuries not related to a monitored object). One of the most frequently used variants of separating these two types of object states is setting of operation regions (adjustment features) of algorithmic parameters complex planes (e.g. the plane of monitored phase impedance ) in a form of polygonal areas in a common case. An adjustment feature should include meterings of monitored object states and exclude meterings of alternative states.
    So it’s necessary to create a function which checks a complex algorithmic metering entry to a polygonal adjustment feature. An adjustment feature is set as a complex numbers array containing operation region peaks first to last. Peaks are following one another clockwise.
    Function code:

%Point – complex point
%Region – region set by complex peaks
function [Result] PtInRegionCplx(Point,Region);
  Eps = 1e-5;
  NPoints = max(size(Region));
  if (Region[1]!=Region[NPoints])
    Region[++NPoints]=Region[1];
  end

  RightCount = 0;
  LeftCount = 0;

  for (n = 1:NPoints-1)
    Rp=real(Point);
    Ip=imag(Point);
    R1=real(Region[n]);
    I1=imag(Region[n]);
    R2=real(Region[n+1]);
    I2=imag(Region[n+1]);

    if (Point==Region[n])
      Result=1;
      return;
    end;

    if (((Ip <= I1) & (Ip > I2)) | ((Ip > I1) & (Ip <= I2)))
      XPoint = R1+(Ip-I1)*(R2-R1)/(I2-I1);
      if (Rp < XPoint)
        RightCount = RightCount+1;
      elseif (Rp > XPoint)
        LeftCount = LeftCount+1;
      else
        Result=1;
        return;
      end;
    elseif ((abs(Ip-I1) < Eps) & (abs(Ip-I2) < Eps))
      if ((Rp > R1) & (Rp > R2))
        LeftCount = LeftCount+1;
      elseif ((Rp < R1) & (Rp < R2))
        RightCount = RightCount+1;
      else
        Result=1;
        return;
      end;
    end;
  end;

  if ((mod(LeftCount,2)==0) | (mod(RightCount,2)==0))
    Result = 0;
  else
    Result = 1;
  end;
end;

    For checking the function working capacity the following code is used:

% Opening the file containing the set polygon points array
ifile=fopen("Data\Region0");
Rgn=fread(ifile);% - Data reading

posplot 1,1;
plot2d #RGN (trans(real(Rgn)),trans(imag(Rgn)),graphtype="#");

percetn=0.1;
rmin=min(real(Rgn));rmin-=percetn*(abs(rmin));
rmax=max(real(Rgn));rmax+=percetn*(abs(rmax));
imin=min(imag(Rgn));imin-=percetn*(abs(imin));
imax=max(imag(Rgn));imax+=percetn*(abs(imax));

% Creation, region entry check and points graphical output to a console
for (k=1:50)
  Pnt[k]=rmin+rnd(abs(rmax)+abs(rmin))+1i*(imin+rnd(abs(imax)+abs(imin)));
  Res[k]=PtInRegionCplx(Pnt[k],Rgn);
  if (Res[k])
    plot2d #RGN (real(Pnt[k]),imag(Pnt[k]),pointstyle="x",
      graphcolor="red",linewidth=3,graphtype=".");
  else
    plot2d #RGN (real(Pnt[k]),imag(Pnt[k]),pointstyle="x",
      graphcolor="blue",linewidth=3, graphtype=".");
  end
end

    The code contains a random set of points within a set region provided by a built-in rnd function, checking of a selected point entry inside the region set by Rgn variable and output of a point right on the graph. Let’s use several files containing complex peaks arrays and get different results by changing a filename in an fopen function delivered parameter.

    Convex area

    Most frequently met characteristics of a relay actuation is made up in a form of quadrangular, heptangular or hexangular convex areas and also in a form on an ellipse or a circle. Let us set a quadrangular convex domain in a "Region0" file:

[0+0i; -3+15i; 40+12i; 25-8i]

         click to view the original size

    Points within the area marked red. Conclusion – the algorithm is efficient for convex domains. Let’s repeat a test involving more complex regions.

    Concave area

    These areas can be met in relay protection less frequently but the point entry check function should be usable for all regions. The "Region1" file contains an array of complex points of a concave area:

[-4-10i; -4-1i; -5+10i; -3-1i; 0+8i; 10+8i; 8-10i]

         click to view the original size

    As it is seen from the graph above the function has successfully accomplished the task of point entry check involving a concave area. As a final test let’s try the function to check the point entry involving saw-toothed areas:

         click to view the original size

<< To the top








2009 CSC-Soft