# simple-flowsheet.in # # Example to show how to hand-build a flowsheet object. The resulting # flowsheet can be optimized using the optimize method in the # Flowsheet class coupled with the appropriate optimization object. In # this example, we use a genetic algorithm for optimizing the flowsheet. # # Copyright (c) 2000, Eric S Fraga, All rights reserved # # ----------------------------------------------------- # # tell the system where to find the classes referenced below use jacaranda.design.ps # for base stream and component classes use jacaranda.design.units # for the unit models and unit variables use jacaranda.design.visual # for visualization tool use jacaranda.util.opt # for genetic algorithm optimisation # # create the two components first # variables variable Base 10 end KistaComponent propane base "45.36/Base * kmol/hr" bp 230.8 cpv -4.224 3.062e-1 -1.586e-4 3.214e-8 lhtc "0.583 *kW/m^2/K" vhtc "5.0 *kW/m^2/K" end KistaComponent nbutane base "226.8/Base * kmol/hr" bp 272.4 cpv 9.487 3.313e-1 -1.108e-4 -2.821e-9 lhtc "0.583 *kW/m^2/K" vhtc "5.0 *kW/m^2/K" end # # now create the feed stream which will be liquid at 1 atm pressure # (default) and temperature chosen automatically to be the bubble # point temperature for that pressure. We also specify that we want # the enthalpy states to be discretized using 32 levels. # Phase phase comps propane nbutane x 0.35 0.65 flow "100 * kmol/hr" phase liquid end PStream feed add phase nstates 32 end # # we have one real unit in the flowsheet: the distillation unit which # separates propane from n-butane, running at 10 atm with a recovery of # 99% for both top and bottom products. The operating pressure is # constrained to be in the range [1,30] and 8 discrete values are # requested within that range. The discrete values are spread # uniformly on a log basis. Note, however, that the flowsheet defined # below works in continuous space so these discrete values are # actually not used. # Distillation D1 LogReal P "10 * atm" "1 *atm" "30 *atm" 8 Real rec 0.99 Component key propane # light key component end # # now describe the units which provide the feed stream and which # accept the products from the distillation unit # # the feed tank has the feed stream defined above # FeedTank Feed Stream feed feed end # # two product tanks, one which accepts streams with 90% propane and # the other with 90% or better n-butane. # ProductTank PropaneTank Expression spec "x[propane]>0.90" # 90% purity of propane in stream end ProductTank NButaneTank Expression spec "x[nbutane]>0.90" end # # lastly, we must define the utilities that are available to meet the # heating and cooling requirements of the flowsheet. These come from # Rathore et al, AIChE J, 1974. # DiscreteUtilities utils hot "Steam @ 28.23 atm" 503.5 503.5 "5000 *W/m^2/K" "1.0246 / GJ" hot "Steam@11.22atm" 457.6 457.6 "5000 *W/m^2/K" "0.773824 / GJ" hot "Steam@4.08atm" 417.0 417.0 "5000 *W/m^2/K" "0.573203 / GJ" hot "Steam@1.70atm" 388.2 388.2 "5000 *W/m^2/K" "0.41796 / GJ" cold "ColdWater@32.2degC" 305.2 305.2 "500 *W/m^2/K" "0.0668737 / GJ" cold "Ammonia@1degC" 274.00 274.00 "500 *W/m^2/K" "1.65035 / GJ" cold "Ammonia@-17.68degC" 255.32 255.32 "500 *W/m^2/K" "2.96871 / GJ" cold "Ammonia@-21.67degC" 251.33 251.33 "500 *W/m^2/K" "3.96226 / GJ" end # # now set the global data based on the objects defined above # Data utils utils end # finally, build up a flowsheet which will be manipulated later using # a genetic algorithm # Flowsheet flowsheet build Feed D1 D1 PropaneTank NButaneTank end continuous # specify continuous optimization end # create the optimizer object that will be used by the flowsheet # object defined below. this optimizer is based on a genetic algorithm # but could be any other sort (check out uk.ac.ucl.che.esf.util.opt.* for some # alternatives or build your own!). the genetic algorithm expects # certain parameters, most of which are defined in the associated # Population object # # crossover rate, between 0 and 1 # elite number of solutions to keep from one generation to the # next # generations number of generations to perform # mutation rate, between 0 and 1 # output level of output desired: 0=none, 1=little, 2=running # stats, >3=verbose to the extreme # # and also expects a population object that will # population size of population VariableEncodedChromosome var function flowsheet end RouletteSelection roulette end Population pop chromosome var # variable encoded chromosome crossover 0.7 # crossover rate (70%) elite 1 # elite set mutation 0.1 # mutation rate (10% -- quite high) n 20 # population size selection roulette # use Roulette wheel fitness based selection end GA ga outputlevel 3 # generate a lot of output ngen 50 # evolve over 50 generations printfrequency 5 # print every 5 population pop # the population object evolve # solve the problem by evolution print # and generate some output end