<commit_before>{% extends "layout.html" %}

{% block content %}

    <!-- Page Content -->
    <div class="container">

        <!-- Website Title -->
        <div class="row">
            <div class="col-lg-12 text-center">
                <h1>A Bootstrap Starter Template</h1>
                <p class="lead">Complete with pre-defined file paths that you won't have to change!</p>
                <ul class="list-unstyled">
                    <li>Bootstrap v3.3.6</li>
                    <li>jQuery v1.11.1</li>
                </ul>
            </div>
        </div>
        <!-- /.row -->

        <!-- Input cycle params -->
        <div class="row">
            <!-- Rankine Cycle Diagram -->
            <div class="col-md-6">
                <img src="../static/img/rankine_cycle-min.jpg" class="img-responsive">
            </div>
            <!-- Parameter Input Form -->
            <div class="col-md-6">
                <form id="cycle-params" class="form-horizontal">
                  <!-- Working Fluid -->
                  <fieldset disabled>
                      <div class="form-group">
                        <label for="workingFluid" class="col-sm-6 control-label">Working Fluid</label>
                        <div class="col-sm-6">
                             <select class="c-select form-control" id="workingFluid">
                              <option selected value="Water">Water</option>
                              <option value="Ammonia">Ammonia</option>
                              <option value="Propane">Propane</option>
                            </select>
                        </div>
                      </div>
                  </fieldset>
                  <!-- High Pressure -->
                  <div class="form-group">
                    <label for="highPressure" class="col-sm-6 control-label">High Pressure</label>
                    <div class="col-sm-6">
                      <input type="number" step="any" min="0" value=10 class="form-control" id="highPressure">
                    </div>
                  </div>
                  <!-- Low Pressure -->
                  <div class="form-group">
                    <label for="lowPressure" class="col-sm-6 control-label">Low Pressure</label>
                    <div class="col-sm-6">
                      <input type="number" step="any" min="0" value=2 class="form-control" id="lowPressure">
                    </div>
                  </div>
                  <!-- Max Temperature -->
                  <div class="form-group">
                    <label for="maxTemperature" class="col-sm-6 control-label">Max Temperature</label>
                    <div class="col-sm-6">
                      <input type="number" step="any" class="form-control" id="maxTemperature">
                    </div>
                  </div>
                  <!-- Turbine Efficiency -->
                  <div class="form-group">
                    <label for="turbineEfficiency" class="col-sm-6 control-label">Turbine Efficiency</label>
                    <div class="col-sm-6">
                      <input type="number" step="any" min="0" max="100" class="form-control" id="turbineEfficiency">
                    </div>
                  </div>
                  <!-- Pump Efficiency -->
                  <div class="form-group">
                    <label for="pumpEfficiency" class="col-sm-6 control-label">Pump Efficiency</label>
                    <div class="col-sm-6">
                      <input type="number" step="any" min="0" max="100" class="form-control" id="pumpEfficiency">
                    </div>
                  </div>
                  <!-- Mass Flow Rate -->
                  <div class="form-group">
                    <label for="massFlowRate" class="col-sm-6 control-label">Mass Flow Rate</label>
                    <div class="col-sm-6">
                      <input type="number" step="any" min="0" class="form-control" id="massFlowRate">
                    </div>
                  </div>
                  <!-- Run cycle button -->
                  <div class="row">
                      <div class="col-sm-6">
                      </div>
                      <div class="col-sm-6">
                          <button type="submit" id="runcycle" class="btn btn-primary btn-lg btn-block pull-right">Run Cycle</button>
                      </div>
                  </div>
                </form>
            </div>
        </div>

        <!-- Results Table -->
        <span id="result">?</span>
        <div id="results" class="show">
            <div class="table-responsive">
                <table id="stateTable" class="table table-bordered">
                    <caption>State Table</caption>
                    <thead>
                        <tr>
                        <th>State</th>
                        <th class="col-sm-2">Temperature</th>
                        <th class="col-sm-2">Pressure</th>
                        <th class="col-sm-2">Volume</th>
                        <th class="col-sm-2">Enthalpy</th>
                        <th class="col-sm-2">Entropy</th>
                        <th class="col-sm-2">Flow Exergy</th>
                        <th class="col-sm-1">Quality</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>1</td>
                            <td>2</td>
                            <td>3</td>
                            <td>4</td>
                            <td>5</td>
                            <td>6</td>
                            <td>7</td>
                            <td>8</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div id="processTable">
                <table class="table table-responsive table-bordered">
                </table>
            </div>
            <div id="cycleResults">
                <table class="table table-responsive table-bordered">
                </table>
            </div>
        </div>

    </div>
    <!-- Javascript for Computing Rankine Cycle -->
         <!-- jQuery Version 1.11.1 -->
    <script type='text/javascript' src="../static/js/jquery.js"></script>
    <script>
        $SCRIPT_ROOT = {{ request.script_root | tojson | safe }};
        $(function() {
            $('#runcycle').on('click', function() {
                $.getJSON($SCRIPT_ROOT + '/_runcycle', {
                    workingFluid: $('#workingFluid').val(),
                    highPressure: $('#highPressure').val(),
                    lowPressure: $('#lowPressure').val()
                }, function(data) {
                    console.table(data);
                    $("#result").text(data.cycle.en_eff * 100);
                    // update state table with data
                    // var $table = $('#stateTableBody');
                    // $table.empty();
                    var rows = '';
                    states = data.cycle.states;
                    for (var i=0, l=states.length; i<l; i++) {
                        state = states[i];
                        var row = '<tr>';
                        console.log(state);
                        data_vars = ['name','T','p','v','h','s','ef','x'];
                        for (var j=0, k=data_vars.length; j<k; j++) {
                            property = data_vars[j];
                            console.log(property);
                            row += '<td>' +  state[property] + '</td>';
                        }
                        console.log(row);
                        rows += row + '</tr>';
                    }
                    console.log(rows);
                    $('#stateTable > tbody').html(rows);
                });
                return false;
            });
        });
    </script>   

{% endblock %}
<commit_msg>add units field and parsefloat<commit_after>{% extends "layout.html" %}

{% block content %}

    <!-- Page Content -->
    <div class="container">

        <!-- Website Title -->
        <div class="row">
            <div class="col-lg-12 text-center">
                <h1>A Bootstrap Starter Template</h1>
                <p class="lead">Complete with pre-defined file paths that you won't have to change!</p>
                <ul class="list-unstyled">
                    <li>Bootstrap v3.3.6</li>
                    <li>jQuery v1.11.1</li>
                </ul>
            </div>
        </div>
        <!-- /.row -->

        <!-- Input cycle params -->
        <div class="row">
            <!-- Rankine Cycle Diagram -->
            <div class="col-md-6">
                <img src="../static/img/rankine_cycle-min.jpg" class="img-responsive">
            </div>
            <!-- Parameter Input Form -->
            <div class="col-md-6">
                <form id="cycle-params" class="form-horizontal">
                  <!-- Working Fluid -->
                      <div class="form-group">
                        <label for="workingFluid" class="col-sm-6 control-label">Working Fluid</label>
                        <div class="col-sm-6">
                             <select disabled class="c-select form-control" id="workingFluid">
                              <option selected value="Water">Water</option>
                              <option value="Ammonia">Ammonia</option>
                              <option value="Propane">Propane</option>
                            </select>
                        </div>
                      </div>
                  </fieldset>
                  <!-- High Pressure -->
                  <div class="form-group">
                    <label for="highPressure" class="col-sm-6 control-label">High Pressure</label>
                    <div class="col-sm-6">
                      <input type="number" step="any" min="0" value=10 class="form-control" id="highPressure">
                    </div>
                  </div>
                  <!-- Low Pressure -->
                  <div class="form-group">
                    <label for="lowPressure" class="col-sm-6 control-label">Low Pressure</label>
                    <div class="col-sm-6">
                      <input type="number" step="any" min="0" value=2 class="form-control" id="lowPressure">
                    </div>
                  </div>
                  <!-- Max Temperature -->
                  <div class="form-group">
                    <label for="maxTemperature" class="col-sm-6 control-label">Max Temperature</label>
                    <div class="col-sm-6">
                      <input disabled type="number" step="any" class="form-control" id="maxTemperature">
                    </div>
                  </div>
                  <!-- Turbine Efficiency -->
                  <div class="form-group">
                    <label for="turbineEfficiency" class="col-sm-6 control-label">Turbine Efficiency</label>
                    <div class="col-sm-6">
                      <input disabled type="number" step="any" min="0" max="100" class="form-control" id="turbineEfficiency">
                    </div>
                  </div>
                  <!-- Pump Efficiency -->
                  <div class="form-group">
                    <label for="pumpEfficiency" class="col-sm-6 control-label">Pump Efficiency</label>
                    <div class="col-sm-6">
                      <input disabled type="number" step="any" min="0" max="100" class="form-control" id="pumpEfficiency">
                    </div>
                  </div>
                  <!-- Mass Flow Rate -->
                  <div class="form-group">
                    <label for="massFlowRate" class="col-sm-6 control-label">Mass Flow Rate</label>
                    <div class="col-sm-6">
                      <input disabled type="number" step="any" min="0" class="form-control" id="massFlowRate">
                    </div>
                  </div>
                  <!-- Units -->
                 <!--<fieldset disabled>-->
                 <div class="form-group">
                        <label for="units" class="col-sm-6 control-label">Units</label>
                        <div class="col-sm-6">
                             <select disabled class="c-select form-control" id="units">
                              <option selected value="si">SI</option>
                              <option value="english">English</option>
                            </select>
                        </div>
                  </div>
                  <!-- Run cycle button -->
                  <div class="row">
                      <div class="col-sm-6">
                      </div>
                      <div class="col-sm-6">
                          <button type="submit" id="runcycle" class="btn btn-primary btn-lg btn-block pull-right">Run Cycle</button>
                      </div>
                  </div>
                </form>
            </div>
        </div>

        <!-- Results Table -->
        <span id="result">?</span>
        <div id="results" class="show">
            <div class="table-responsive">
                <table id="stateTable" class="table table-bordered">
                    <caption>State Table</caption>
                    <thead>
                        <tr>
                        <th>State</th>
                        <th class="col-sm-2">Temperature</th>
                        <th class="col-sm-2">Pressure</th>
                        <th class="col-sm-2">Volume</th>
                        <th class="col-sm-2">Enthalpy</th>
                        <th class="col-sm-2">Entropy</th>
                        <th class="col-sm-2">Flow Exergy</th>
                        <th class="col-sm-1">Quality</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>1</td>
                            <td>2</td>
                            <td>3</td>
                            <td>4</td>
                            <td>5</td>
                            <td>6</td>
                            <td>7</td>
                            <td>8</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div id="processTable">
                <table class="table table-responsive table-bordered">
                </table>
            </div>
            <div id="cycleResults">
                <table class="table table-responsive table-bordered">
                </table>
            </div>
        </div>

    </div>
    <!-- Javascript for Computing Rankine Cycle -->
         <!-- jQuery Version 1.11.1 -->
    <script type='text/javascript' src="../static/js/jquery.js"></script>
    <script>
        $SCRIPT_ROOT = {{ request.script_root | tojson | safe }};
        $(function() {
            $('#runcycle').on('click', function() {
                $.getJSON($SCRIPT_ROOT + '/_runcycle', {
                    workingFluid: $('#workingFluid').val(),
                    highPressure: $('#highPressure').val(),
                    lowPressure: $('#lowPressure').val()
                }, function(data) {
                    console.table(data);
                    $("#result").text(data.cycle.en_eff * 100);
                    // update state table with data
                    // var $table = $('#stateTableBody');
                    // $table.empty();
                    var rows = '';
                    states = data.cycle.states;
                    for (var i=0, l=states.length; i<l; i++) {
                        state = states[i];
                        var row = '<tr>';
                        console.log(state);
                        data_vars = ['name','T','p','v','h','s','ef','x'];
                        for (var j=0, k=data_vars.length; j<k; j++) {
                            property = data_vars[j];
                            console.log(property);
                            row += '<td>' +  parseFloat(state[property]).toFixed(2) + '</td>';
                        }
                        console.log(row);
                        rows += row + '</tr>';
                    }
                    console.log(rows);
                    $('#stateTable > tbody').html(rows);
                });
                return false;
            });
        });
    </script>   

{% endblock %}

{'fraction_non_alphanumeric': 0.14910041332360807, 'fraction_numerical': 0.008327255044979333, 'mean_word_length': 1.044358846918489, 'pattern_counts': {'":': 0, '<': 369, '<?xml version=': 0, '>': 367, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6477069', 'n_tokens_mistral': 4343, 'n_tokens_neox': 4004, 'n_words': 799}