User:Ujjavalverma10
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 have prior experience with GUI development and would be applying for projects involving GUI development. 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.
Partitioned Model for FRUSTUM OF A CONE
Following is a modified version of the Frustum MODEL which breaks down a frustum into two cones : A top cone cut out from a bottom cone.
REQUIRE "atoms.a4l"; MODEL cone; (* variables *) R, h, l IS_A distance; curved_area IS_A area; vol IS_A volume; (* equations *) l = sqrt(h^2 + R^2); vol = 3.1416*h*R^2/3; curved_area = 3.1416*l*R; METHODS METHOD specify; FIX R; FIX h; END specify; END cone; MODEL partitioned_frustrum_of_cone; (* variables *) R, r, h IS_A distance; l IS_A distance; curved_area, total_area IS_A area; vol IS_A volume; metal_density IS_A mass_density; metal_mass IS_A mass; (* parts *) top IS_A cone; bottom IS_A cone; (* specifications *) R = 30.0 {cm}; r = 10.0 {cm}; h = 50.0 {cm}; metal_density = 9.60 {g/cm^3}; (* equations *) top.R = r; top.h = r*h/(R-r); bottom.R = R; bottom.h = h + top.h; l = bottom.l - top.l; vol = bottom.vol - top.vol; curved_area = bottom.curved_area - top.curved_area; total_area = 3.1416*(R^2 + r^2) + curved_area; metal_mass = metal_density*vol; END partitioned_frustrum_of_cone;