Overview
Comment:Polytropic CR (for SimpleGasTurbine).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 896433377bf8bf7335116448a0c4f6a2016ddc2675d0e901e96deb88720b56ea
User & Date: geraint@users.sourceforge.net on 2004-09-02 21:51:30
Other Links: branch diff | manifest | tags
Context
2004-09-02
21:52:04
Density CR (for SimpleGasTurbine). check-in: 4b5a41d739 user: geraint@users.sourceforge.net tags: origin/master, trunk
21:51:30
Polytropic CR (for SimpleGasTurbine). check-in: 896433377b user: geraint@users.sourceforge.net tags: origin/master, trunk
21:50:49
Require EXACT match of component type (so that TF doesn't match EMTF, etc.) check-in: e777591396 user: geraint@users.sourceforge.net tags: origin/master, trunk
Changes

Added mttroot/mtt/lib/cr/perl/Poly.pm version [8d57733efc].



























































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#-------------------------------------------------------------------------------
#			Model Transformation Tools
#-------------------------------------------------------------------------------


package Poly;

#-------------------------------------------------------------------------------
#		Polytropic constitutive relationship 
#-------------------------------------------------------------------------------

use strict;
use warnings;

#-------------------------------------------------------------------------------
# standard module header (see perlmod for explanation)
#-------------------------------------------------------------------------------
BEGIN {
    use Exporter   ();
    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);

    $VERSION     = 1.00;

    @ISA         = qw(Exporter);
    @EXPORT      = qw(&Poly);	# CR name
    %EXPORT_TAGS = ( );
}

#-------------------------------------------------------------------------------
# declaration of specific component implementations
#-------------------------------------------------------------------------------
sub Poly_any(@);		# any component

#-------------------------------------------------------------------------------
# main function: selects which subfunction to call
#-------------------------------------------------------------------------------
sub Poly (@) {

    my $retval;

    $_ = $_[0];

    s/\((.*)\)/$1/;		# strip brackets
    my @args = split (/,/);	# split arguments

    $_ = $args[0];		# get component type

    # select rule to use
    $retval = Poly_any	(@args);
    
    # if a substitution has been made ($retval)
    if ($retval)
    {
	return $retval;		# return substituted expression
    }
    else			# return nothing
    {
	return;
    }
}

#-------------------------------------------------------------------------------
# any component
#-------------------------------------------------------------------------------
sub Poly_any (@) {

    my @args = @_;
    my $retval = '';

    if ($#args == 16-1)
    {
	my ($component,
	    $alpha,
	    $out_causality,
	    $out_port,
	    $P1,
	    $in1_causality,
	    $in1_port,
	    $P2,
	    $in2_causality,
	    $in2_port,
	    $T1,
	    $in3_causality,
	    $in3_port,
	    $Nothing,
	    $in4_causality,
	    $in4_port) = @args;

	if (($in1_port == 1) and
	    ($in1_causality eq 'effort') and
	    ($in2_port == 2) and
	    ($in2_causality eq 'effort') and
	    ($in3_port == 3) and
	    ($in3_causality eq 'effort') and
	    ($in4_port == 4) and
	    ($in4_causality eq 'flow'))
	{
	    if ($out_port != 4)
	    {
		return "(0)";
	    }
	    elsif ($out_causality eq 'effort')
	    {
		# return temperature T2
		$retval = "($T1)*pow((($P2)/($P1)),($alpha))";
	    }
	}
    }
    
    if ($retval)
    {
	return $retval;
    }
    else
    {
	return;
    }
}

#-------------------------------------------------------------------------------
1;				# return true


MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]