Skip to content

Repository files navigation

Python_CERA

Table of Contents

[TOC]

General information

Introduction

​ This project man target is to translate an old Fortran77 application, to a new Python language. OOP technology need to be used in the final project output. Source code for Fortran77 is included in this application documents.

​ Fortran source code

FolderFiles CountLines Count
Cab194,636
Cycle179,112
Menu3920,656
cyc600a1173
User Manual11
Total7734,578

Project target

  1. Convert an application, from old Fortran77 to Python.
  2. Translate the source-code language of CERA from Fortran to Python. This should include testing and verification of the translation to ensure that source code operates effectively under the new version. Deliverable: A source code of CERA converted to python
  3. Improve and change the source-code architecture to Object-Oriented Programing Deliverable: A source code converted to an object-oriented programming
  4. Develop a simplified text input interface using simplified text editors or Microsoft Excel and a simplified output format using a comma- or tab-delimited format that can be read in different tools (text editors or Microsoft Excel) Deliverable: The text input and output interfaces using simplified text editors or Microsoft Excel completed

Cycle Solver is a solver in Python for refrigerator cycle. it contains a group of class as shown in graph:

Philosophy

​ To make the output of Python application debug is more simple, the main function names and variable name will be the same in Python application. It is not normal to use caps for variable names in Python, but we used caps variables name, to be similar as the Fortran source. Methods name was set in small letters, but the same as function names in Fortran.

CoolProb utility is used as an alternative to Fortran library which do the same task.

​ Some other Python classes was created as an alternative to old dos function, for example Python FileAcccess class.

​ Fortran source has some issue, that was clear after transfer application to Python :-

  • Some variables is not used

  • Some calculated values is not used nor printed in reports.

Application Basic design in Python (3.8)

​ The application is divided into two main parts, namely Cab and Cycle application. Each has its own OOP structure, and inputs and outputs. Some class is used in both application (see /common_classes)

Cab application (save in App/cab_classes)

​ Analyses of the cabinet loads. The steady-state heat inputs to the cabinet section are determined for various configuration refrigerator/freezers, alternative insulation system designs, and specified environment and usage conditions.

Cab Application OOP structure
cab_oop.png
Cycle Application (save in App/cycle_classes)

​ Determination of the steady-state, instantaneous, refrigeration cycle capacity and power draws. The hourly average cabinet loads and instantaneous refrigeration capacities determine the compressor duty cycle and the corresponding fan powers.

Cycle Application OOP structure
cycle_oop.png

Input / Output entry values to application

​ Both application inputs is a CSV file, to make the thing more easy an Excel Sheet(s) was made to each application to enter the inputs, later user will save file as CSV for application to run. Output also is a CSV files that is created by application and could be browsed by simple text editor or by Excel.

​ Folder (data) was created as the preferred location for data inputs/output for both application, but user can select his/her preferred folder name and file name. User has to follow the given structure for the inputs file as the sample in data folder, or application will raise an error.

FunctionFile Name / LocationFolderComment
Cab Inputcab_dat.csvdatacab_input_R13.xlsx, in folder (input_intertface)
Cab Outputcab_out.csvdata
cab4cyc_out.csvdatacreated as an input for Cycle
Cycle Inputcycle_dat.csvdatacyc_input_R11.xlsx, in folder (input_interface)
and cab4cyc_out.csvdatacame from Cab output.
Cycle Outputcycle_out.csvdata

Application Configuration

Step 01: Check folder input_interface and adjust the input for Cab or/and Cycle application using cab_input.xlsx for Cab, or cyc_input.xlsx for cycle application.

Step 02: Save file as *.csv file in data folder, with name as listed in the above table.

Step 03: Alterative option is to use Excel or normal some text editor to edit csv files. In case it is required to use another file name in another folder other than the default, you need to edit the running script to point to the required file and/or folder (see below).

Step 04: Run the related script.

Step 05: If no error in input data, Cab and Cycle or (app to run both in one script) application will create csv for output. default name for output csv files will be as listed in the above table, or other name if user edit the running script as mentioned in Step 03.

Edit Running application

Edit app_start script to point to input and output files for both Cab and Cycle application, the variable is found in other scripts cab_start or Run Cycle application cycle_start

FILE_CAB_INPUT="cab_dat.csv"# input file for cabinit moduleFILE_CAB_OUTPUT="cab_out.csv"# output file for cabinit moduleFILE_CAB2CYC="cab2cyc_out.csv"# output file for cabinit moduleFILE_CYC_INPUT="cycle_dat.csv"# input file for cycle moduleFILE_CYC_OUTPUT="cycle_out.csv"# output file for cycle module# rest script code

Running Application

​ There is tow applications, and one script to run both application is sequence. so it takes the output of Cab application and send it as an input to Cycle application.

Run application: use cab_start or Run Cycle application cycle_start

Run both by one script useapp_start

Cab Application Classes

List of all application files with approximate 14,573 lines count .

File NameClass DescriptionLines Count (approximate)
CabData.pyReads data from input file, and save it in QData object (in common classes)417
CabUtils.pyUtility to Cab calculation131
DoorOpen.pyUtility to Cab calculation for Qlxxx classes427
QCtrl.pyClass to select the required class to use according to inputs flag736
Ql13.pyCab calculation for types mode 1 & 3526
Ql2.pyCab calculation for types mode 2745
Ql467.pyCab calculation for types mode 1, 4, 6, 7493
Ql5.pyCab calculation for types mode 5275
Ql8.pyCab calculation for types mode 8501
Start.pyStart class for Cab application237
View.pyCab reporter1,218
Volume.pyCab calculation for Volume292
Total5,998

Cycle Application Classes

File NameClass DescriptionLines Count (approximate)
CabData.pyRead input data for cycle, came from Cab application383
CompMap.pyCompressor Map utility420
Compressor.pyCompressor calculations468
Condenser.pyCondenser calculations1,077
CoolPrp.pyCall CoolProp utility238
CoolPrpUtil.pyUtility function for CoolPrp class83
CycData.pyRead input data for cycle383
CycleSolver.pyMain cycle solver1,290
CycleType.pyCycle solver utility447
CycleUtils.pyCycle solver utility893
ErrorException.pyError handler20
Evaporator.pyEvaporator calculations834
exf4Cond_Evap.pyUtility for heat exchanger106
ShowInput.pyPrint information, input, PID and others264
Start.pyStart class for Cycle application176
Trace.pyUsed to select to print or not a group(s) of point, that print data in a selected places196
View.pyCycle reporter645
Total7,540

Common Classes

File NameClass DescriptionLines Count (approximate)
DataModelBuiler.pyParent class from other class to read csv files and save data to python QDATA class325
FileAccess.pyRead & writes to csv files.242
Unit.pyControl to convert between Britch and SI units.194
QData.pyClass to save data from csv file(s).274
Total1,035

About

Convert CERA Fortran77 to Python 3.8

Topics

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages