#============================================================================== # This file contains Nial definitions not directly used by the Expert System # for Flowsheet Synthesis. They are used primarily for the second part of # the expert system, that which converts separators into actual separation # sequences and processes. This portion of the project has not yet been # integrated with XESFFS but can be used interactively if you know what # you're doing. #============================================================================== lowercase:=each charrep ('abcdefghijklmnopqrstuvwxyz'); uppercase:=each charrep ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'); average is /[sum,tally]link make_report is external operation; pick_coord IS OPERATION Coord { IF first Coord < second Coord THEN Coord ELSE Null ENDIF } recode IS OPERATION Arg { IF charrep Arg in Lowercase THEN char ( ( charrep Arg ) + 64 ) ELSE Arg ENDIF } scoreop IS OPERATION Db&cpd Addr { Db Cpd := Db&cpd ; (rule1 Db Cpd Addr) + (rule2 Db Cpd Addr) + (rule3 Db Cpd Addr) + (rule4 Addr) } separate IS OPERATION Spt Cpd { (((tally Cpd) - Spt) dropright Cpd)(Spt drop Cpd) } split_at IS OPERATION Db&cpd Addr { Pass_weight := last Ctrl_info ; Db Cpd := Db&cpd ; IF rule0 Cpd THEN l ELSE ((rule1 Db Cpd Addr)+(rule2 Db Cpd Addr)+(rule3 Db Cpd Addr)+(rule4 Addr)) >= Pass_weight ENDIF } simple_syn IS OPERATION Db Compound { IF pure Compound THEN phrase Compound ELSE Addresses := front count tally Compound ; Split_pts := ((Db Compound) EACHRIGHT split_at Addresses) sublist Addresses ; Sub_cpds := Split_pts EACHLEFT separate Compound ; phrase Compound pair (Db EACHRIGHT EACHRIGHT simple_syn Sub_cpds) ENDIF } split_ops IS OPERATION Db Str { Result := Null; Addresses := front count tally Str; Scores := (Db Str) EACHRIGHT scoreop Addresses; Result := Result append Scores; Result } efficient_syn IS OPERATION Compound { NONLOCAL Dynamic; IF pure Compound THEN phrase Compound ELSE Addresses := front count tally Compound; Code Scores := getunit Dynamic [(phrase Compound)] "SCORE; IF first Code = Falsehood THEN Scores := (Thermo Compound) EACHRIGHT scoreop Addresses; Code Dynamic := insertnote Dynamic ((phrase Compound) Scores) "Add; ENDIF ; Split_pts := (link Scores >= last Ctrl_info) sublist Addresses; Sub_cpds := Split_pts EACHLEFT separate Compound; phrase Compound pair (TWIG efficient_syn Sub_cpds) ENDIF } splits IS OPERATION Db Cpd { No_of_comp := tally Cpd; I := 2; Result := Null; REPEAT Mask := tell I; REPEAT Subcpd := Mask choose Cpd; Result := Result append (( phrase Subcpd) link split_ops Db Subcpd); Mask := Mask + 1; UNTIL last Mask = No_of_comp ENDREPEAT; I := I + 1; UNTIL I > No_of_comp ENDREPEAT; Result } busi IS OPERATION Compounds Molefrac { NONLOCAL Temp Pressure thermo; N := tally Compounds; Thermo := selectnotes Major_therm ["NAME]["in][Compounds]; Thermo := insertzone Thermo Molefrac ("MOLEFFRAC "isinclude "pass o "picture); Temp := average second pullzones Thermo ["BP]; Pressure := read ' enter system pressure : '; %formulate k_values, sorting thm db; Break; Thermo := SORTNOTES > (attachzone Thermo ["ANTOINE] "calculate_k ("K "isinclude "pass o "picture o))["K]; Break; K := first second pullzones Thermo ["K]; Alphas := (front K) EACHBOTH div (rest K); alphas:= 0. link alphas; Thermo := insertzone Thermo Alphas ("ALPHA "isinclude "pass o "picture); %formulate the index, and the alpha s; Index := EACH (phrase char)((tell N) choose Uppercase); Thermo := insertzone Thermo Index ("INDEX "isinclude "pass o "picture); Break; Feedstream := link EACH string (first second pullzones Thermo ["INDEX]); Ring_bell; feedline 10; say ' Identifying sequences ......'; feedline 1; Break; Simple_seq := efficient_syn Thermo Feedstream; make_report Simple_seq; } busi IS OPERATION Compounds Molefrac { NONLOCAL Temp Pres Dynamic thermo; Dynamic := EACH makezones (("COMPOUND "SCORE)("isalphabet "isinclude) ("string "string)(l o)("picture "picture))[][]; N := tally Compounds; Thermo := selectnotes Major_therm ["NAME]["in][Compounds]; Thermo := insertzone Thermo Molefrac ("MOLEFFRAC "isinclude "pass o "picture); Temp := average link second pullzones Thermo ["BP]; Pres := read ' enter system pressure : '; %formulate k_values, sorting thm db; Thermo := SORTNOTES > (attachzone Thermo ["ANTOINE] "calculate_k ("K "isinclude "pass o "picture))["K]; K := first second pullzones Thermo ["K]; Alphas := (front K) EACHBOTH div (rest K); Alphas := 0. link Alphas; Thermo := insertzone Thermo Alphas ("ALPHA "isinclude "pass o "picture); %formulate the index, and the alpha s; Index := EACH (phrase char)((tell N) choose Uppercase); Thermo := groupnotes (insertzone Thermo Index ("INDEX "isinclude "pass o "picture))["INDEX]; Feedstream := link EACH string (first second pullzones Thermo ["INDEX]); Ring_bell; feedline 10; say ' Identifying sequences ......'; feedline 1; Simple_seq := efficient_syn Feedstream; Break; make_report Simple_seq; }