// Build a fake load subsystem for a vg_b.
// The model consists of adjustable drop in series with a fixed
// drop. fx is frozen.  Equivalent to vg_b.
// Author:       D. A. Gutz
// Written:      14-Sep-92
// Revisions:    21-Sep-92    Unfroze pr & pr_sens.
//               29-Sep-92    Added vol_rcham.
//               29-Sep-92    Rewrote because non-working.
// 
//Input:
// dpav1         Variable load drop, psi.
// dpav2         Fixed load drop, psi.
// wfl           Load flow, pph.
// cd            Coefficient of discharge.
// sg            Specific gravity.
// vol_rcham     Rod chamber volume.
// beta          Fuel compressibility, psi.
// 
// Differential IO:
// pd            Input # 1, supply pressure, psi.
// pr            Input # 2, drain pressure, psi.
// per           Input # 3, actuator end pressure, psi.
// wfld          Input # 4, load flow demand, mA.
// fx            Input # 5, load, lbf pullin.
// wfh_sens      Input # 6, head sense flow out of ehsv, pph.
// wfr_sens      Input # 7, rod sense flow out of ehsv, pph.
// wfs           Output # 1, supply flow in, pph.
// wfr           Output # 2, drain flow out, pph.
// wfve          Output # 3, actuator end flow pulled in by rod, pph.
// ph_sens       Output # 4, head sensed pressure at ehsv, psi.
// pr_sens       Output # 5, rod sensed pressure at ehsv, psi.
// ph            Output # 6, head pressure at actuator, psi.
// pr            Output # 7, rod pressure at actuator, psi.
// v_sv          Output # 8, EHSV spool velocity toward head end, in/s.
// x_sv          Output # 9, EHSV spool displacement toward head, in.
// v_act         Output # 10, actuator velocity toward head end, in/s.
// x_act         Output # 11, actuator  displacement toward head, in.
// 
// Local:
// fake_ehsv     Variable load.
// fake_act      Fixed load.
// tee_pr        Flow tee for pr.
// dummy         Dummy for null i/o.
// tee_sum_pr    Sum flow to tee_pr.
// 
// Functions called:
// m_valve_a     Variable valve.
// summer        sum.
// dor_aptow     Fixed drop.
// Copyright (C) 2018 - Dave Gutz
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// Sep 26, 2018 	DA Gutz		Created
// *****************************************************************************
function [sys] = lti_fake_vg_b(dpav1,dpav2,wfl,%cd,sg,vol_rcham,%beta)

    // Output variables initialisation (not found in input variables)
    sys=[];

    // Display mode
    mode(0);

    // Display warning for floating point exception
    ieee(1);

    // Parameters.
    // none.

    fake_ehsv = lti_m_valve_a(0, dpav1, wfl);
    tee_pr = lti_vol_1(vol_rcham, %beta, sg);
    fake_act = lti_dor_aptow(wfl,dpav2, 0, %cd, sg);
    tee_sum_pr = summer(1, 1, 0, 0);
    dummy = summer(0, 0, 0, 0);

    // Make system.
    sys = adjoin(fake_ehsv, tee_pr, fake_act, tee_sum_pr, dummy);

    // Inputs.
    us = [1, 7, 13, 3, 14, 15, 9];

    // Outputs.
    ys = [1, 3, 5, 5, 2, 5, 2, 5, 5, 5, 5];

    // Connections.
    qs = [2,2; 4,1; 5,4; 6,2; 10,3];

    // Form the system.
    sys = connect_ss(sys, qs, us, ys);

endfunction
