User:Ujjavalverma10: Difference between revisions

From ASCEND
Jump to navigation Jump to search
Created page with '==A simple model of 'Frustum of A cone'== We construct the following ASCEND model for this problem. <source lang="a4c"> REQUIRE "system.a4l"; MODEL frustrum_of_cone; …'
 
Line 1: Line 1:
==A simple model of 'Frustum of A cone'==
==A simple model for FRUSTUM OF A CONE==


We construct the following ASCEND model for this problem.     
I am new to the ASCEND language and intend to contribute something to the community through GSOC2011. I wrote a sample model for Frustum Of A Cone     


<source lang="a4c">
<source lang="a4c">
Line 57: Line 57:
</source>
</source>


This [[MODEL]] is quite straight forward to write.  ASCEND uses strong typing; it requires one to declare explicitly the type of each variable using [[IS_A]] statements. Any [[variable]] whose value it is expected to compute must be of at least type "solver_var," the type we have used here.  (Note that we insert a first statement to "require" that a file called "system.a4l" loads first as it contains the definition for the type "solver_var.")
This [[MODEL]] is quite straight forward to write.  ASCEND uses strong typing; it requires one to declare explicitly the type of each variable using [[IS_A]] statements.

Revision as of 07:43, 2 April 2011

A simple model for FRUSTUM OF A CONE

I am new to the ASCEND language and intend to contribute something to the community through GSOC2011. I wrote a sample model for Frustum Of A Cone


REQUIRE "system.a4l";
MODEL frustrum_of_cone;

    (* variables *)
    R,
    h,
    r,
    l,
    metal_density,
    curved_area,
    total_area,
    vol,
    metal_mass      IS_A solver_var;
    (* specifications *)
    R              = 30.0;
    r		   = 10.0;
    h              = 50.0;
    metal_density  = 9.60;
    
    (* equations *)
    l = sqrt(h^2 + (R-r)^2);
    vol = 3.1416*h*(R^2 + r^2 + r*R)/3;
    curved_area = 3.1416*l*(R+r);
    total_area = 3.1416*(R^2 + r^2) + curved_area;
    metal_mass = metal_density*vol;
    
METHODS

   METHOD specify;
      FIX R;
      FIX r;
      FIX h;
      FIX metal_density;
   END specify;

   METHOD values;
      R              := 30.0 ;
      r		     := 10.0;
      h              := 50.0;
      metal_density  := 9.60 ;

   END values;

   METHOD setup;
      RUN specify;
      RUN values;
   END setup;
    
END frustrum_of_cone;

This MODEL is quite straight forward to write. ASCEND uses strong typing; it requires one to declare explicitly the type of each variable using IS_A statements.