/* Copyright Renaud GICQUEL 2026 renaud.gicquel@s4e2.com Ce logiciel est un programme informatique servant à modéliser des systèmes énergétiques. Ce logiciel est régi par la licence CeCILL soumise au droit français et respectant les principes de diffusion des logiciels libres. Vous pouvez utiliser, modifier et/ou redistribuer ce programme sous les conditions de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA sur le site "http://www.cecill.info". En contrepartie de l'accessibilité au code source et des droits de copie, de modification et de redistribution accordés par cette licence, il n'est offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons, seule une responsabilité restreinte pèse sur l'auteur du programme, le titulaire des droits patrimoniaux et les concédants successifs. A cet égard l'attention de l'utilisateur est attirée sur les risques associés au chargement, à l'utilisation, à la modification et/ou au développement et à la reproduction du logiciel par l'utilisateur étant donné sa spécificité de logiciel libre, qui peut le rendre complexe à manipuler et qui le réserve donc à des développeurs et des professionnels avertis possédant des connaissances informatiques approfondies. Les utilisateurs sont donc invités à charger et tester l'adéquation du logiciel à leurs besoins dans des conditions permettant d'assurer la sécurité de leurs systèmes et ou de leurs données et, plus généralement, à l'utiliser et l'exploiter dans les mêmes conditions de sécurité. Le fait que vous puissiez accéder à cet en-tête signifie que vous avez pris connaissance de la licence CeCILL, et que vous en avez accepté les termes. This software is a computer program whose purpose is to model energy systems. This software is governed by the CeCILL license under French law and abiding by the rules of distribution of free software. You can use, modify and/ or redistribute the software under the terms of the CeCILL license as circulated by CEA, CNRS and INRIA at the following URL "http://www.cecill.info". As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license, users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the successive licensors have only limited liability. In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or developing or reproducing the software by the user in light of its specific status of free software, that may mean that it is complicated to manipulate, and that also therefore means that it is reserved for developers and experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the software's suitability as regards their requirements in conditions enabling the security of their systems and/or data to be ensured and, more generally, to use and operate it in the same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. */ package extThopt; import javax.swing.*; import java.awt.*; import java.util.*; import rg.corps.*; /** * Classe pour calculer un cycle à vapeur en régime non-nominal * * le modèle de turbine est celui de Stodola, en version multi-étagée * * @author Renaud GICQUEL */ public class SimpleSteamPlantControllerOptim extends ExtPilot implements optimization.Lmdif_fcn { boolean isInitialized=false; boolean isBuilt=false; String[]component,componentName,nozzleName; String turbineName="",boilerName,condenserName, evapSettings="", condSettings=""; TechnoHx technoBoiler, technoCond; TechnoMultiStageTurb technoTurbine; double DeltaHcond,Te,Tf,massFlow, DTsurch, DTssrefr, Aevap, Acond, AevapReal, AcondReal, Uevap, Ucond; double tauTurb, DeltaHevap, mCpmin, mCpmax, NUT,R,epsilon, AdesignBoiler, AdesignCond, lambdaVol; double TamontCompr, PamontCompr, UAevap, UAcond,DeltaH0,T2,Tevap, Pevap,Vevap,Hevap,DeltaH_NH3, Twater, DHcompr, rotationSpeed, Pcond, mCpRefrigBoiler, mCpRefrigCond, mCpCalopBoiler, mCpCalopCond, Tcond, RVL; double a0_value=0.96, alpha_value=0.038, Kh=872.7969721981, Vs_value=0.0199, Tsuperheating, gasFlow, eta_is; double qlv_cond,qlv_evap; PointThopt boilerUpstream, boilerDownstream, condUptream, condDownstream, hotGases, inRiver, coldGases, outRiver; String tab=new String("\t"); String ligne=new String("\n"); Corps subst; final ButtonGroup groupAlgorithm=new ButtonGroup(); // epsmch is the machine precision static final double epsmch = 2.22044604926e-16; int nfev = 0; int njev = 0; int nfev2 = 0; int njev2 = 0; public SimpleSteamPlantControllerOptim() { //{{INIT_CONTROLS setTitle("Steam power plant controller"); getContentPane().setLayout(null); setSize(640,590); setVisible(false); bInitialSettings.setText("Initial settings"); bInitialSettings.setActionCommand("load"); getContentPane().add(bInitialSettings); bInitialSettings.setBounds(420,12,156,36); JLabel6.setText("high pressure"); getContentPane().add(JLabel6); JLabel6.setForeground(new java.awt.Color(102,102,153)); JLabel6.setBounds(312,192,156,24); getContentPane().add(Pevap_value); Pevap_value.setBounds(480,192,100,24); Pevap_value.setSelectionColor(new java.awt.Color(204,204,255)); Pevap_value.setSelectedTextColor(java.awt.Color.black); Pevap_value.setCaretColor(java.awt.Color.black); Pevap_value.setDisabledTextColor(new java.awt.Color(153,153,153)); JLabel4.setText("low pressure"); getContentPane().add(JLabel4); JLabel4.setForeground(java.awt.Color.red); JLabel4.setBounds(12,360,156,24); Pcond_value.setSelectionColor(new java.awt.Color(204,204,255)); Pcond_value.setSelectedTextColor(java.awt.Color.black); Pcond_value.setCaretColor(java.awt.Color.black); Pcond_value.setDisabledTextColor(new java.awt.Color(153,153,153)); Pcond_value.setEditable(false); getContentPane().add(Pcond_value); Pcond_value.setBounds(180,360,120,24); AdesignCond_value.setSelectionColor(new java.awt.Color(204,204,255)); AdesignCond_value.setSelectedTextColor(java.awt.Color.black); AdesignCond_value.setCaretColor(java.awt.Color.black); AdesignCond_value.setDisabledTextColor(new java.awt.Color(153,153,153)); getContentPane().add(AdesignCond_value); AdesignCond_value.setBounds(480,96,100,24); JLabel5.setText("set condenser area"); getContentPane().add(JLabel5); JLabel5.setForeground(new java.awt.Color(102,102,153)); JLabel5.setBounds(312,96,156,24); bCalculate.setText("Calculate "); bCalculate.setActionCommand("Calculate "); getContentPane().add(bCalculate); bCalculate.setBounds(432,324,156,60); JLabel10.setText("Design settings"); getContentPane().add(JLabel10); JLabel10.setForeground(java.awt.Color.blue); JLabel10.setFont(new Font("Dialog", Font.BOLD, 18)); JLabel10.setBounds(12,12,553,25); UAcond_value.setSelectionColor(new java.awt.Color(204,204,255)); UAcond_value.setSelectedTextColor(java.awt.Color.black); UAcond_value.setCaretColor(java.awt.Color.black); UAcond_value.setDisabledTextColor(new java.awt.Color(153,153,153)); UAcond_value.setEditable(false); getContentPane().add(UAcond_value); UAcond_value.setBounds(480,60,100,24); JLabel12.setText("condenser UA"); getContentPane().add(JLabel12); JLabel12.setBounds(312,60,156,24); JLabel13.setText("set boiler area"); getContentPane().add(JLabel13); JLabel13.setForeground(new java.awt.Color(102,102,153)); JLabel13.setBounds(12,96,161,22); AdesignBoiler_value.setSelectionColor(new java.awt.Color(204,204,255)); AdesignBoiler_value.setSelectedTextColor(java.awt.Color.black); AdesignBoiler_value.setCaretColor(java.awt.Color.black); AdesignBoiler_value.setDisabledTextColor(new java.awt.Color(153,153,153)); getContentPane().add(AdesignBoiler_value); AdesignBoiler_value.setBounds(180,96,100,24); JLabel14.setText("Stodola constant"); getContentPane().add(JLabel14); JLabel14.setBounds(12,192,150,23); Kh_value.setSelectionColor(new java.awt.Color(204,204,255)); Kh_value.setSelectedTextColor(java.awt.Color.black); Kh_value.setCaretColor(java.awt.Color.black); Kh_value.setDisabledTextColor(new java.awt.Color(153,153,153)); getContentPane().add(Kh_value); Kh_value.setBounds(180,192,100,24); JLabel16.setText("DeltaH boiler"); getContentPane().add(JLabel16); JLabel16.setForeground(java.awt.Color.red); JLabel16.setBounds(324,396,144,24); DeltaHevap_value.setSelectionColor(new java.awt.Color(204,204,255)); DeltaHevap_value.setSelectedTextColor(java.awt.Color.black); DeltaHevap_value.setCaretColor(java.awt.Color.black); DeltaHevap_value.setDisabledTextColor(new java.awt.Color(153,153,153)); DeltaHevap_value.setEditable(false); getContentPane().add(DeltaHevap_value); DeltaHevap_value.setBounds(480,396,120,24); JLabel15.setText("boiler UA"); getContentPane().add(JLabel15); JLabel15.setBounds(12,60,156,24); UAevap_value.setSelectionColor(new java.awt.Color(204,204,255)); UAevap_value.setSelectedTextColor(java.awt.Color.black); UAevap_value.setCaretColor(java.awt.Color.black); UAevap_value.setDisabledTextColor(new java.awt.Color(153,153,153)); UAevap_value.setEditable(false); getContentPane().add(UAevap_value); UAevap_value.setBounds(180,60,100,24); JLabel1.setText("flow rate"); getContentPane().add(JLabel1); JLabel1.setForeground(java.awt.Color.red); JLabel1.setBounds(12,468,156,24); massFlow_value.setSelectionColor(new java.awt.Color(204,204,255)); massFlow_value.setSelectedTextColor(java.awt.Color.black); massFlow_value.setCaretColor(java.awt.Color.black); massFlow_value.setDisabledTextColor(new java.awt.Color(153,153,153)); massFlow_value.setEditable(false); getContentPane().add(massFlow_value); massFlow_value.setBounds(180,468,120,24); JLabel2.setText("cooling temperature (°C)"); getContentPane().add(JLabel2); JLabel2.setBounds(12,228,156,24); Teau_value.setText("5"); Teau_value.setSelectionColor(new java.awt.Color(204,204,255)); Teau_value.setSelectedTextColor(java.awt.Color.black); Teau_value.setCaretColor(java.awt.Color.black); Teau_value.setDisabledTextColor(new java.awt.Color(153,153,153)); getContentPane().add(Teau_value); Teau_value.setBounds(180,228,100,24); JLabel3.setText("turbine power"); getContentPane().add(JLabel3); JLabel3.setForeground(java.awt.Color.red); JLabel3.setBounds(324,432,156,24); tauTurb_value.setSelectionColor(new java.awt.Color(204,204,255)); tauTurb_value.setSelectedTextColor(java.awt.Color.black); tauTurb_value.setCaretColor(java.awt.Color.black); tauTurb_value.setDisabledTextColor(new java.awt.Color(153,153,153)); tauTurb_value.setEditable(false); getContentPane().add(tauTurb_value); tauTurb_value.setBounds(480,432,120,24); JLabel7.setText("DeltaH cond"); getContentPane().add(JLabel7); JLabel7.setForeground(java.awt.Color.red); JLabel7.setBounds(12,432,156,24); DeltaHcond_value.setSelectionColor(new java.awt.Color(204,204,255)); DeltaHcond_value.setSelectedTextColor(java.awt.Color.black); DeltaHcond_value.setCaretColor(java.awt.Color.black); DeltaHcond_value.setDisabledTextColor(new java.awt.Color(153,153,153)); DeltaHcond_value.setEditable(false); getContentPane().add(DeltaHcond_value); DeltaHcond_value.setBounds(180,432,120,24); JLabel8.setText("Simulation results"); getContentPane().add(JLabel8); JLabel8.setForeground(java.awt.Color.red); JLabel8.setFont(new Font("Dialog", Font.BOLD, 18)); JLabel8.setBounds(12,324,553,25); JLabel9.setText("calculated boiler area"); getContentPane().add(JLabel9); JLabel9.setBounds(12,132,156,24); AcalculatedBoiler_value.setSelectionColor(new java.awt.Color(204,204,255)); AcalculatedBoiler_value.setSelectedTextColor(java.awt.Color.black); AcalculatedBoiler_value.setCaretColor(java.awt.Color.black); AcalculatedBoiler_value.setDisabledTextColor(new java.awt.Color(153,153,153)); AcalculatedBoiler_value.setEditable(false); getContentPane().add(AcalculatedBoiler_value); AcalculatedBoiler_value.setBounds(180,132,100,24); JLabel11.setText("calculated condenser area"); getContentPane().add(JLabel11); JLabel11.setBounds(312,132,156,24); AcalculatedCond_value.setSelectionColor(new java.awt.Color(204,204,255)); AcalculatedCond_value.setSelectedTextColor(java.awt.Color.black); AcalculatedCond_value.setCaretColor(java.awt.Color.black); AcalculatedCond_value.setDisabledTextColor(new java.awt.Color(153,153,153)); AcalculatedCond_value.setEditable(false); getContentPane().add(AcalculatedCond_value); AcalculatedCond_value.setBounds(480,132,100,24); JLabel17.setText("Efficiency"); getContentPane().add(JLabel17); JLabel17.setForeground(java.awt.Color.red); JLabel17.setBounds(324,468,156,24); eff_value.setSelectionColor(new java.awt.Color(204,204,255)); eff_value.setSelectedTextColor(java.awt.Color.black); eff_value.setCaretColor(java.awt.Color.black); eff_value.setDisabledTextColor(new java.awt.Color(153,153,153)); eff_value.setEditable(false); getContentPane().add(eff_value); eff_value.setBounds(480,468,120,24); JLabel20.setText("max temperature (°C)"); getContentPane().add(JLabel20); JLabel20.setBounds(312,228,156,24); Tmax_value.setText("560"); Tmax_value.setSelectionColor(new java.awt.Color(204,204,255)); Tmax_value.setSelectedTextColor(java.awt.Color.black); Tmax_value.setCaretColor(java.awt.Color.black); Tmax_value.setDisabledTextColor(new java.awt.Color(153,153,153)); getContentPane().add(Tmax_value); Tmax_value.setBounds(480,228,100,24); oneStepAlgorithm.setText("one step algorithm"); oneStepAlgorithm.setActionCommand("one step algorithm"); getContentPane().add(oneStepAlgorithm); oneStepAlgorithm.setBounds(12,276,168,24); twoStepAlgorithm.setText("two steps algorithm"); twoStepAlgorithm.setActionCommand("two steps algorithm"); getContentPane().add(twoStepAlgorithm); twoStepAlgorithm.setBounds(204,276,168,24); jcheckReInitialize.setText("reinitialize"); jcheckReInitialize.setActionCommand("reinitialize"); getContentPane().add(jcheckReInitialize); jcheckReInitialize.setBounds(432,276,152,20); getContentPane().add(algorithmResults); algorithmResults.setBounds(192,324,222,26); JLabel18.setText("DeltaH compr"); getContentPane().add(JLabel18); JLabel18.setForeground(java.awt.Color.red); JLabel18.setBounds(12,396,144,24); DeltaHcompr_value.setSelectionColor(new java.awt.Color(204,204,255)); DeltaHcompr_value.setSelectedTextColor(java.awt.Color.black); DeltaHcompr_value.setCaretColor(java.awt.Color.black); DeltaHcompr_value.setDisabledTextColor(new java.awt.Color(153,153,153)); DeltaHcompr_value.setEditable(false); getContentPane().add(DeltaHcompr_value); DeltaHcompr_value.setBounds(180,396,120,24); getContentPane().add(JList1); JList1.setBounds(216,540,20,40); //}} //{{REGISTER_LISTENERS SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); bInitialSettings.addActionListener(lSymAction); bCalculate.addActionListener(lSymAction); //}} //{{INIT_MENUS //}} type="Steam plant controller"; groupAlgorithm.add(oneStepAlgorithm); groupAlgorithm.add(twoStepAlgorithm); oneStepAlgorithm.setSelected(true); } /** * returns the component type public String getCompType(){ return type; }**/ public String getClassDescription(){ return "pilot for a steam cycle with simple turbine\n\n\nauthor : R. Gicquel august 2009"; } void setupProject(){ //on récupère ici les instances des transfos externes dont on a besoin //afin d'accéder à leurs différents paramètres pour les calculs ultérieurs } public void setVisible(boolean b) { if(b) { setLocation(50, 50); } super.setVisible(b); } public void addNotify() { // Record the size of the window prior to calling parents addNotify. Dimension d = getSize(); super.addNotify(); if (fComponentsAdjusted) return; // Adjust components according to the insets Insets ins = getInsets(); setSize(ins.left + ins.right + d.width, ins.top + ins.bottom + d.height); Component components[] = getContentPane().getComponents(); for (int i = 0; i < components.length; i++) { Point p = components[i].getLocation(); p.translate(ins.left, ins.top); components[i].setLocation(p); } fComponentsAdjusted = true; } // Used for addNotify check. boolean fComponentsAdjusted = false; class SymWindow extends java.awt.event.WindowAdapter { public void windowClosing(java.awt.event.WindowEvent event) { Object object = event.getSource(); if (object == SimpleSteamPlantControllerOptim.this) Thrust_WindowClosing(event); } } void Thrust_WindowClosing(java.awt.event.WindowEvent event) { dispose(); // dispose of the Frame. } //{{DECLARE_CONTROLS javax.swing.JButton bInitialSettings = new javax.swing.JButton(); javax.swing.JLabel JLabel6 = new javax.swing.JLabel(); javax.swing.JTextField Pevap_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel4 = new javax.swing.JLabel(); javax.swing.JTextField Pcond_value = new javax.swing.JTextField(); javax.swing.JTextField AdesignCond_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel5 = new javax.swing.JLabel(); javax.swing.JButton bCalculate = new javax.swing.JButton(); javax.swing.JLabel JLabel10 = new javax.swing.JLabel(); javax.swing.JTextField UAcond_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel12 = new javax.swing.JLabel(); javax.swing.JLabel JLabel13 = new javax.swing.JLabel(); javax.swing.JTextField AdesignBoiler_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel14 = new javax.swing.JLabel(); javax.swing.JTextField Kh_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel16 = new javax.swing.JLabel(); javax.swing.JTextField DeltaHevap_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel15 = new javax.swing.JLabel(); javax.swing.JTextField UAevap_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel1 = new javax.swing.JLabel(); javax.swing.JTextField massFlow_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel2 = new javax.swing.JLabel(); javax.swing.JTextField Teau_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel3 = new javax.swing.JLabel(); javax.swing.JTextField tauTurb_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel7 = new javax.swing.JLabel(); javax.swing.JTextField DeltaHcond_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel8 = new javax.swing.JLabel(); javax.swing.JLabel JLabel9 = new javax.swing.JLabel(); javax.swing.JTextField AcalculatedBoiler_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel11 = new javax.swing.JLabel(); javax.swing.JTextField AcalculatedCond_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel17 = new javax.swing.JLabel(); javax.swing.JTextField eff_value = new javax.swing.JTextField(); javax.swing.JLabel JLabel20 = new javax.swing.JLabel(); javax.swing.JTextField Tmax_value = new javax.swing.JTextField(); javax.swing.JRadioButton oneStepAlgorithm = new javax.swing.JRadioButton(); javax.swing.JRadioButton twoStepAlgorithm = new javax.swing.JRadioButton(); javax.swing.JCheckBox jcheckReInitialize = new javax.swing.JCheckBox(); javax.swing.JLabel algorithmResults = new javax.swing.JLabel(); javax.swing.JLabel JLabel18 = new javax.swing.JLabel(); javax.swing.JTextField DeltaHcompr_value = new javax.swing.JTextField(); javax.swing.JList JList1 = new javax.swing.JList(); //}} //{{DECLARE_MENUS //}} class SymAction implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent event) { Object object = event.getSource(); if (object == bInitialSettings) bInitialSettings_actionPerformed(event); else if (object == bCalculate) bCalculate_actionPerformed(event); } } public void init(){ isInitialized=true; proj=getProjet(); setupProject(); //initialisations des PointThopt et des TechnoDesign //initializations for simulation boilerUpstream=new PointThopt(proj,"2"); boilerDownstream=new PointThopt(proj,"3b"); condUptream=new PointThopt(proj,"4"); condDownstream=new PointThopt(proj,"1"); hotGases=new PointThopt(proj,"hot gas"); coldGases=new PointThopt(proj,"cooled gas"); inRiver=new PointThopt(proj,"river inlet"); outRiver=new PointThopt(proj,"river outlet"); condDownstream.getProperties(); subst=(rg.corps.Corps)condDownstream.lecorps; //noms des composants / component names boilerName="boiler"; condenserName="condenser"; turbineName="turbine"; //instanciation des TechnoDesign dans les classes externes //instanciation of TechnoDesign in external classes technoBoiler=new TechnoEvaporator(proj, boilerName, hotGases, coldGases, boilerUpstream, boilerDownstream); addTechnoVector(technoBoiler); technoCond=new TechnoCondensor(proj, condenserName, condUptream, condDownstream, inRiver, outRiver); addTechnoVector(technoCond); technoTurbine= new TechnoMultiStageTurb(proj, turbineName, boilerDownstream, condUptream); addTechnoVector(technoTurbine); //initialisation des TechnoDesign dans Thermoptim / TechnoDesign initialisation setupTechnoDesigns(vTechno); technoBoiler.qlv=qlv_evap; technoCond.qlv=qlv_cond; // System.out.println(" piloteVapeur qlv "+qlv_cond);//+" hf "+te.tHx.techf.h+" ro_l "+ro_l+" ro_v "+ro_v); } void bInitialSettings_actionPerformed(java.awt.event.ActionEvent event){ if(!isInitialized)init();//la première fois, on initialise, car il faut un constructeur sans argument //pour instancier la classe par le RMI String[] args=new String[2]; args[0]="project"; args[1]=""; Vector vProp=proj.getProperties(args); String flowUnit=(String)vProp.elementAt(0); if(!flowUnit.equals("kg/s")){ String msg = "Watch out! the flow rate unit should be\"kg/s\".\nYou may have discrepancies between your units \nand those used for heat exchanger design"; JOptionPane.showMessageDialog(this, msg); } //pour plus de sûreté, le test pourrait porter sur l'existence de l'échangeur dans le projet if(!boilerName.equals("")){//initialization of the boiler args=new String[2]; args[0]="heatEx"; args[1]=boilerName; vProp=proj.getProperties(args); Double f=(Double)vProp.elementAt(15); UAevap=f.doubleValue(); String fluideChaud=(String)vProp.elementAt(0); args[0]="process"; args[1]=fluideChaud; vProp=proj.getProperties(args); f=(Double)vProp.elementAt(4); double DeltaH=-f.doubleValue(); f=(Double)vProp.elementAt(3); gasFlow=f.doubleValue(); boilerUpstream.getProperties(); boilerDownstream.getProperties(); DTsurch=boilerDownstream.DTsat; hotGases.getProperties(); coldGases.getProperties(); Tf=hotGases.T; mCpCalopBoiler=DeltaH/(hotGases.T-coldGases.T); mCpRefrigBoiler=DeltaH/(boilerDownstream.T-boilerUpstream.T); DeltaHevap=DeltaH; UAevap_value.setText(Util.aff_d(UAevap,4)); Tmax_value.setText(Util.aff_d(boilerDownstream.T-273.15,4)); Pevap_value.setText(Util.aff_d(boilerDownstream.P,4)); //initializations of the TechnoDesign technoBoiler.makeDesign(); AevapReal=Util.lit_d(technoBoiler.ADesign_value.getText()); //Uevap sera utilisé ultérieurement pour actualiser UAevap Uevap=technoBoiler.UA/AevapReal; AcalculatedBoiler_value.setText(technoBoiler.ADesign_value.getText()); } if(!condenserName.equals("")){//initialisation du condenseur / condenser initialization args=new String[2]; args[0]="heatEx"; args[1]=condenserName; vProp=proj.getProperties(args); Double f=(Double)vProp.elementAt(15); UAcond=f.doubleValue(); String fluideFroid=(String)vProp.elementAt(1); args[0]="process"; args[1]=fluideFroid; vProp=proj.getProperties(args); f=(Double)vProp.elementAt(4); double DeltaH=f.doubleValue(); condDownstream.getProperties(); condUptream.getProperties(); DTssrefr=condDownstream.DTsat; inRiver.getProperties(); outRiver.getProperties(); Twater=inRiver.T; Teau_value.setText(Util.aff_d(Twater-273.15,4)); mCpCalopCond=DeltaH/(outRiver.T-inRiver.T); mCpRefrigCond=DeltaH/(condUptream.T-condDownstream.T); UAcond_value.setText(Util.aff_d(UAcond,4)); //initialisations du TechnoDesign technoCond.makeDesign(); AcondReal=Util.lit_d(technoCond.ADesign_value.getText()); //Ucond sera utilisé ultérieurement pour actualiser UAcond Ucond=technoCond.UA/AcondReal; AcalculatedCond_value.setText(technoCond.ADesign_value.getText()); } if(!turbineName.equals("")){//initialization of the steam turbine args=new String[2]; args[0]="process"; args[1]=turbineName; vProp=proj.getProperties(args); String amont=(String)vProp.elementAt(1); String aval=(String)vProp.elementAt(2); Double f=(Double)vProp.elementAt(3); massFlow=f.doubleValue(); f=(Double)vProp.elementAt(11); eta_is=f.doubleValue(); Kh=technoTurbine.getStodolaConstant(); Kh_value.setText(Util.aff_d(Kh,4)); RVL=0; } } void bCalculate_actionPerformed(java.awt.event.ActionEvent event){ calculatePilot(); } public void calculatePilot(){ if(!isInitialized)init();//la première fois, on initialise, car il faut un constructeur sans argument //pour instancier la classe par le RMI //parameters and variables are read on the controller screen AdesignBoiler=Util.lit_d(AdesignBoiler_value.getText()); AdesignCond=Util.lit_d(AdesignCond_value.getText()); Kh=Util.lit_d(Kh_value.getText()); technoTurbine.setKh(Kh); UAevap=Util.lit_d(UAevap_value.getText()); UAcond=Util.lit_d(UAcond_value.getText()); Pevap=Util.lit_d(Pevap_value.getText()); boilerDownstream.P=Pevap; boilerDownstream.T=Util.lit_d(Tmax_value.getText())+273.15; boilerDownstream.update(UPDATE_T,UPDATE_P,!UPDATE_X); boilerDownstream.getProperties(); boilerUpstream.P=Pevap; boilerUpstream.update(!UPDATE_T,UPDATE_P,!UPDATE_X); boilerUpstream.getProperties(); Twater=Util.lit_d(Teau_value.getText())+273.15; //initialisation des températures de changement d'état //initialization of phase change temperatures if(jcheckReInitialize.isSelected()){//if "reinitialize" is checked Tcond= condDownstream.T+Twater-inRiver.T; } else{ Tcond=subst.getSatTemperature(condDownstream.P, 1); } inRiver.T=Twater; inRiver.update(UPDATE_T,!UPDATE_P,!UPDATE_X); inRiver.getProperties(); condUptream.getProperties(); condDownstream.getProperties(); DTsurch=boilerDownstream.DTsat; DTssrefr=condDownstream.DTsat; algorithmResults.setText(""); int m = 4; int n = 4; double fvec[] = new double[m+1]; double x[] = new double[n+1]; int info[] = new int[2]; int iflag[] = new int[2]; x[1] = Tcond; x[2] = massFlow; x[3] = UAevap; x[4] = UAcond; double residu0; double residu1; fcn(m,n,x,fvec,iflag); residu0 = optimization.Minpack_f77.enorm_f77(m,fvec); nfev2 = 0; njev2 = 0; double epsi=0.0005;//précision globale demandée sur la convergence / overall accuracy required on the convergence double epsfcn = 1.e-6;//précision calcul des différences finies finies / precision of finite differences calculus if(twoStepAlgorithm.isSelected()){ epsi=0.01; } //appel modifié de lmdiff avec modification précision calcul des différences finies //modified call to lmdiff with precision change in the calculus of finite differences optimization.Minpack_f77.lmdif2_f77(this, m, n, x, fvec, epsi, epsfcn, info); residu1 = optimization.Minpack_f77.enorm_f77(m,fvec); System.out.println(); System.out.println(" Initial L2 norm of the residuals: " + residu0); System.out.println("Final L2 norm of the residuals: " + residu1); System.out.println("Number of function evaluations: " + nfev); System.out.println("Number of Jacobian evaluations: " + njev); System.out.println("Info value: " + info[1]); System.out.println("Final approximate solution: " + x[1] + ", " + x[2]+ ", " + x[3] ); System.out.println(); algorithmResults.setText("Algorithm precision: " + Util.aff_d(residu1,8)); if(twoStepAlgorithm.isSelected()){ epsi=0.00005; epsfcn = 1.e-9;//précision calcul des différences finies finies / precision of finite differences calculus //appel modifié de lmdiff avec modification précision calcul des différences finies //modified call to lmdiff with precision change in the calculus of finite differences optimization.Minpack_f77.lmdif2_f77(this, m, n, x, fvec, epsi, epsfcn, info); residu1 = optimization.Minpack_f77.enorm_f77(m,fvec); System.out.println(); System.out.println(" Initial L2 norm of the residuals: " + residu0); System.out.println("Final L2 norm of the residuals: " + residu1); System.out.println("Number of function evaluations: " + nfev); System.out.println("Number of Jacobian evaluations: " + njev); System.out.println("Info value: " + info[1]); System.out.println("Final approximate solution: " + x[1] + ", " + x[2]+ ", " + x[3] ); System.out.println(); /**/ algorithmResults.setText("Algorithm precision: " + Util.aff_d(residu1,8)); } eff_value.setText(Util.aff_d(-tauTurb/DeltaHevap,4)); DeltaHevap_value.setText(Util.aff_d(DeltaHevap,4)); massFlow_value.setText(Util.aff_d(massFlow,4)); DeltaHcond_value.setText(Util.aff_d(DeltaHcond,4)); Pevap_value.setText(Util.aff_d(Pevap,4)); Pcond_value.setText(Util.aff_d(condDownstream.P,4)); tauTurb_value.setText(Util.aff_d(tauTurb,4)); DeltaHcompr_value.setText(Util.aff_d(DHcompr,4)); } public void fcn(int m, int n, double x[], double fvec[], int iflag[]) { if (iflag[1]==1) this.nfev++; if (iflag[1]==2) this.njev++; //mise à jour des variables "physiques" pour une meilleure compréhension du code //Update of "physical" variables for a better understanding of the code Tcond=x[1]; massFlow=x[2]; UAevap=x[3]; UAcond=x[4]; updateprocess(turbineName, "Expansion",RECALCULATE,IS_SET_FLOW, UPDATE_FLOW, massFlow, UPDATE_ETA, eta_is); Vector vProp; Double f; //mise à jour du point aval du condenseur (avec modification du sous-refroidissement) //Update of point downstream of the condenser (with modification of sub-cooling) Pcond=subst.getSatPressure(Tcond, 1); condDownstream.T=Tcond+DTssrefr;// DTssrefr est négatif / DTssrefr is negative condDownstream.P=Pcond; condDownstream.T=subst.getSatTemperature(condDownstream.P,1)+DTssrefr;// DTssrefr est négatif condDownstream.DTsat=DTssrefr; condDownstream.update(UPDATE_T, UPDATE_P, !UPDATE_X, false, UPDATE_DTSAT, false, "", 0.); condDownstream.getProperties(); double Hl=condDownstream.H; DHcompr=condDownstream.V*(boilerDownstream.P-condDownstream.P)*100;//prise en compte de la compression liquide / liquid compression Hl=Hl+DHcompr; DHcompr=DHcompr*massFlow; condUptream.P=Pcond; condUptream.update(!UPDATE_T,UPDATE_P,!UPDATE_X); condUptream.getProperties(); //new DeltaHevap DeltaHevap=massFlow*(boilerDownstream.H-Hl); mCpRefrigBoiler=DeltaHevap/(boilerDownstream.T-condDownstream.T); double[]res=Util.epsi_NUT(mCpRefrigBoiler,mCpCalopBoiler,UAevap); epsilon=res[0]; mCpmin=res[1]; Tf=boilerUpstream.T+DeltaHevap/epsilon/mCpmin; hotGases.T=Tf; hotGases.update(UPDATE_T,!UPDATE_P,!UPDATE_X); coldGases.T=Tf-DeltaHevap/gasFlow; coldGases.update(UPDATE_T,!UPDATE_P,!UPDATE_X); hotGases.getProperties(); coldGases.getProperties(); //calcul de la turbine / calculation of the turbine DeltaHcond=DeltaHevap+getTurbinePower(); condUptream.getProperties(); //calcul des premiers résidus / calculation of first residuals fvec[1] = resCond(); fvec[2] = resFlow(); //mises à jour du simulateur avant recalcul des TechnoDesign //on les exécute 3 fois par sécurité, mais ce n'est pas optimisé // Updates the simulator before recalculating the TechnoDesign // It is running three times as a safety, but it is not optimized for(int j=0;j<3;j++)proj.calcThopt(); updateHx(boilerName, RECALCULATE, !UPDATE_UA, 0, !UPDATE_EPSI, 0, !UPDATE_DTMIN, 0); updateHx(condenserName, RECALCULATE, !UPDATE_UA, 0, !UPDATE_EPSI, 0, !UPDATE_DTMIN, 0); updateHx(boilerName, RECALCULATE, !UPDATE_UA, 0, !UPDATE_EPSI, 0, !UPDATE_DTMIN, 0); updateHx(condenserName, RECALCULATE, !UPDATE_UA, 0, !UPDATE_EPSI, 0, !UPDATE_DTMIN, 0); updateHx(boilerName, RECALCULATE, !UPDATE_UA, 0, !UPDATE_EPSI, 0, !UPDATE_DTMIN, 0); updateHx(condenserName, RECALCULATE, !UPDATE_UA, 0, !UPDATE_EPSI, 0, !UPDATE_DTMIN, 0); boilerUpstream.getProperties(); boilerDownstream.getProperties(); condUptream.getProperties(); condDownstream.getProperties(); hotGases.getProperties(); coldGases.getProperties(); inRiver.getProperties(); outRiver.getProperties(); technoBoiler.makeDesign(); AcalculatedBoiler_value.setText(technoBoiler.ADesign_value.getText()); technoCond.makeDesign(); AcalculatedCond_value.setText(technoCond.ADesign_value.getText()); //calcul des derniers résidus après recalcul des TechnoDesign (adimensionnés) // Calculates the last residuals after recalculating the TechnoDesign (dimensionless) fvec[3] = resAevap(); fvec[4] = resAcond(); } double getTurbinePower(){ Vector vProp; Double f; //recalcul de la turbine / Recalculation of the turbine double eta_is=technoTurbine.getRisentr(); updateprocess(turbineName, "Expansion",RECALCULATE,IS_SET_FLOW, UPDATE_FLOW, massFlow, UPDATE_ETA, eta_is); //ce qui permet de connaître la puissance consommée / Which allows to know the power consumption String[] args=new String[2]; args[0]="process"; args[1]=turbineName; vProp=proj.getProperties(args); f=(Double)vProp.elementAt(4); tauTurb=f.doubleValue(); double tauIs=tauTurb/eta_is; return tauTurb; } double resCond(){//équation 17.4.5 //renvoie la différence entre la température de condensation //recalculée à partir de la méthode du NUT et Tcond=x[1] // Returns the difference between the condensation temperature // recalculated using the NTU method and Tcond = x [1] double Toutlet_refrig=0; mCpRefrigCond=DeltaHcond/(condUptream.T-(Tcond+DTssrefr)); double[] res=Util.epsi_NUT(mCpRefrigCond,mCpCalopCond,UAcond); epsilon=res[0]; mCpmin=res[1]; double Tinlet_refrig=Twater+DeltaHcond/epsilon/mCpmin; Toutlet_refrig=Tinlet_refrig-DeltaHcond/mCpRefrigCond; //le résidu est l'écart entre les deux températures de condensation // The residual is the difference between the two condensing temperatures double z= Tcond-(Toutlet_refrig-DTssrefr); z= 2*z/(Tcond+Toutlet_refrig-DTssrefr); System.out.println("resCond: " + z + ", "+ Tcond + ", " + Tevap+ ", " + massFlow ); return z; } double resAevap(){//renvoie le résidu de la surface de l'évaporateur UAevap_value.setText(Util.aff_d(UAevap,4)); AcalculatedBoiler_value.setText(Util.aff_d(AevapReal,4)); AevapReal=technoBoiler.A; double z= AevapReal-AdesignBoiler; System.out.println(); z= 2*z/(AevapReal+AdesignBoiler); System.out.println("resAevap: " + z + ", "+ UAevap + ", " + UAcond); return z; } double resAcond(){//renvoie le résidu de la surface du condenseur / returns the residual of the condenser surface UAcond_value.setText(Util.aff_d(UAcond,4)); AcalculatedCond_value.setText(Util.aff_d(AcondReal,4)); AcondReal=technoCond.A; double z= AcondReal-AdesignCond; z= 2*z/(AcondReal+AdesignCond); System.out.println("resAcond: " + z + ", "+ UAevap + ", " + UAcond); return z; } double resFlow(){//équations 17.4.1 et 17.4.2 //renvoie le résidu du débit-masse //recalcul du débit d'eau // Returns the remainder of the mass flow // Recalculate the flow of water double y=technoTurbine.getMassFlow(); double z= massFlow-y; z= 2*z/(massFlow+y); System.out.println("resFlow: " + z + ", "+ Tcond + ", " + Tevap+ ", " + massFlow ); return z; } public void readCompParameters(String ligne_data){ String value=""; value=Util.extr_value(ligne_data, "mCpRefrigBoiler"); if(!(value==null)){ mCpRefrigBoiler=Util.lit_d(value); } value=Util.extr_value(ligne_data, "mCpRefrigCond"); if(!(value==null)){ mCpRefrigCond=Util.lit_d(value); } value=Util.extr_value(ligne_data, "Kh"); if(!(value==null)){ Kh=Util.lit_d(value); Kh_value.setText(Util.aff_d(Kh,4)); } value=Util.extr_value(ligne_data, "UAevap"); if(!(value==null)){ UAevap=Util.lit_d(value); UAevap_value.setText(Util.aff_d(UAevap,4)); } value=Util.extr_value(ligne_data, "UAcond"); if(!(value==null)){ UAcond=Util.lit_d(value); UAcond_value.setText(Util.aff_d(UAcond,4)); } value=Util.extr_value(ligne_data, "mCpCalopBoiler"); if(!(value==null)){ mCpCalopBoiler=Util.lit_d(value); AcalculatedBoiler_value.setText(Util.aff_d(mCpCalopBoiler,4)); } value=Util.extr_value(ligne_data, "mCpCalopCond"); if(!(value==null)){ mCpCalopCond=Util.lit_d(value); AcalculatedCond_value.setText(Util.aff_d(mCpCalopCond,4)); } value=Util.extr_value(ligne_data, "DeltaHevap"); if(!(value==null)){ DeltaHevap=Util.lit_d(value); DeltaHevap_value.setText(Util.aff_d(DeltaHevap,4)); } value=Util.extr_value(ligne_data, "DeltaHcond"); if(!(value==null)){ DeltaHcond=Util.lit_d(value); DeltaHcond_value.setText(Util.aff_d(DeltaHcond,4)); } value=Util.extr_value(ligne_data, "tauTurb"); if(!(value==null)){ tauTurb=Util.lit_d(value); tauTurb_value.setText(Util.aff_d(tauTurb,4)); } value=Util.extr_value(ligne_data, "RVL"); if(!(value==null)){ RVL=Util.lit_d(value); technoTurbine.display_value.setText(Util.aff_d(RVL,4)); } value=Util.extr_value(ligne_data, "AdesignBoiler"); if(!(value==null)){ AdesignBoiler=Util.lit_d(value); AdesignBoiler_value.setText(Util.aff_d(AdesignBoiler,4)); } value=Util.extr_value(ligne_data, "AdesignCond"); if(!(value==null)){ AdesignCond=Util.lit_d(value); AdesignCond_value.setText(Util.aff_d(AdesignCond,4)); } if(!(value==null)){ qlv_cond=Util.lit_d(value); technoCond.qlv=qlv_cond; //System.out.println(" relecture piloteVapeur qlv "+qlv_cond);//+" hf "+te.tHx.techf.h+" ro_l "+ro_l+" ro_v "+ro_v); } value=Util.extr_value(ligne_data, "qlv_evap"); if(!(value==null)){ qlv_evap=Util.lit_d(value); technoBoiler.qlv=qlv_evap; } value=Util.extr_value3(ligne_data, "technoBoiler"); if(!(value==null)){ evapSettings=value; if(technoBoiler!=null)technoBoiler.readCaract(value); } value=Util.extr_value3(ligne_data, "technoCond"); if(!(value==null)){ condSettings=value; if(technoCond!=null)technoCond.readCaract(value); } } public String saveCompParameters(){ String h="mCpRefrigBoiler="+Util.aff_d(mCpRefrigBoiler)+tab +"mCpRefrigCond="+Util.aff_d(mCpRefrigCond)+tab +"Kh="+Util.aff_d(Kh)+tab +"UAevap="+Util.aff_d(UAevap)+tab +"UAcond="+Util.aff_d(UAcond)+tab +"mCpCalopBoiler="+Util.aff_d(mCpCalopBoiler)+tab +"mCpCalopCond="+Util.aff_d(mCpCalopCond)+tab +"DeltaHevap="+Util.aff_d(DeltaHevap)+tab +"DeltaHcond="+Util.aff_d(DeltaHcond)+tab +"tauTurb="+Util.aff_d(tauTurb)+tab +"AdesignBoiler="+AdesignBoiler_value.getText()+tab +"AcalculatedBoiler="+AcalculatedBoiler_value.getText()+tab +"AdesignCond="+AdesignCond_value.getText()+tab +"AcalculatedCond="+AcalculatedCond_value.getText()+tab +"RVL="+Util.aff_d(RVL)+tab +"DHcompr="+Util.aff_d(DHcompr)+tab +"qlv_cond="+Util.aff_d(technoCond.qlv)+tab +"qlv_evap="+Util.aff_d(technoBoiler.qlv)+tab +"#technoBoiler="+technoBoiler.saveCaract()+"#"+tab +"#technoCond="+technoCond.saveCaract()+"#"+tab ; return h; } }