# Contents of /trunk/models/johnpye/cavity.a4c

Wed Mar 1 13:53:45 2006 UTC (18 years, 3 months ago) by johnpye
File MIME type: text/x-ascend
File size: 2667 byte(s)
```Adding a better base-case
```
 1 REQUIRE "atoms.a4l"; 2 3 ATOM energy_rate_per_length REFINES solver_var 4 DIMENSION M*L/T^3 5 DEFAULT 1000{W/m}; 6 lower_bound := -1e50{W/m}; 7 upper_bound := 1e50{W/m}; 8 nominal := 1000{W/m}; 9 END energy_rate_per_length; 10 11 ATOM energy_flux REFINES solver_var 12 DIMENSION M/T^3 13 DEFAULT 1000{W/m^2}; 14 lower_bound := -1e50{W/m^2}; 15 upper_bound := 1e50{W/m^2}; 16 nominal := 1000{W/m^2}; 17 END energy_flux; 18 19 MODEL cavity; 20 W,B,S,N,C,E,D IS_A distance; 21 theta, phi, psi IS_A angle; 22 23 F_WN, F_WW, F_WB IS_A factor; 24 F_NB, F_NW, F_NN, F_BW, F_BN IS_A factor; 25 F_WS IS_A factor; 26 27 N * sin(theta) = D; 28 S * tan(theta) = D; 29 B = W + 2 * S; 30 E^2 = W^2 + D^2; 31 phi = arctan(D/W); 32 psi = 1{PI} - phi; 33 C^2 = E^2 + S^2 - 2* E * S * cos(psi); 34 35 F_WN = (W+N-C)/2/W; 36 F_WW = (2*E-2*D)/2/W; 37 F_WB = 1 - 2 * F_WN; 38 F_WS = (1 - 2 * F_WN - F_WB)/2; 39 F_NB = (N+B-C)/2/N; 40 F_NW = (N+W-C)/2/N; 41 42 F_BN = F_NB*N/B; 43 F_NN = 1 - F_NW - F_NB; 44 F_BW = F_WB*W/B; 45 46 n IS_A set OF symbol_constant; 47 n :== ['W','B','L','R']; 48 49 (* Put lengths into a vector *) 50 51 A[n] IS_A distance; 52 A['W'], W ARE_THE_SAME; 53 A['B'], B ARE_THE_SAME; 54 A['L'], N ARE_THE_SAME; 55 A['R'], N ARE_THE_SAME; 56 57 (* View factor matrix *) 58 59 F[n][n] IS_A factor; 60 61 F['W']['L'], F['W']['R'], F_WN ARE_THE_SAME; 62 F['W']['B'], F_WB ARE_THE_SAME; 63 F['W']['W'] = 0; 64 65 F['B']['L'], F['B']['R'], F_BN ARE_THE_SAME; 66 F['B']['W'], F_BW ARE_THE_SAME; 67 F['B']['B'] = 0; 68 69 F['L']['R'], F['R']['L'], F_NN ARE_THE_SAME; 70 F['L']['B'], F['R']['B'], F_NB ARE_THE_SAME; 71 F['L']['W'], F['R']['W'], F_NW ARE_THE_SAME; 72 F['L']['L'] = 0; 73 F['R']['R'] = 0; 74 75 (* Radiation equations *) 76 q[n] IS_A energy_rate_per_length; 77 78 E_b[n] IS_A energy_flux; 79 J[n] IS_A energy_flux; 80 T[n] IS_A temperature; 81 eps[n] IS_A factor; (* emissivity *) 82 83 FOR i IN n CREATE 84 q[i] = SUM[ (J[i]-J[j])*(A[i]*F[i][j]) | j IN n]; 85 END FOR; 86 87 FOR i IN n CREATE 88 E_b[i] = 1{SIGMA_C} * T[i]^4; 89 END FOR; 90 91 FOR i IN n CREATE 92 q[i] * (1-eps[i]) = (E_b[i] - J[i]) * (eps[i]*A[i]); 93 END FOR; 94 95 METHODS 96 METHOD default_self; 97 RUN reset; RUN values; RUN bound_self; 98 END default_self; 99 100 METHOD bound_self; 101 phi.lower_bound := 0 {deg}; 102 phi.upper_bound := 90 {deg}; 103 psi.lower_bound := 90 {deg}; 104 psi.upper_bound := 180 {deg}; 105 END bound_self; 106 107 METHOD specify; 108 FIX T['W', 'B']; 109 FIX q['L','R']; 110 FIX W,D,theta; 111 FIX eps[n]; 112 END specify; 113 114 METHOD values; 115 T['W'] := 550 {K}; 116 T['B'] := 373.15 {K}; 117 q['L','R'] := 0 {W/m}; 118 119 W := 500 {mm}; 120 D := 300 {mm}; 121 theta := 30 {deg}; 122 123 eps['W'] := 0.49; 124 eps['B'] := 0.9; 125 eps['L','R'] := 0.1; 126 127 END values; 128 129 END cavity;