-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
191 lines (182 loc) · 5.91 KB
/
test.ts
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
// import { OutputModCHP, OutputModGP, OutputModGPO } from '@ucdavis/tea/out/models/output.model';
// import dotenv from 'dotenv';
// import knex from 'knex';
// import OSRM from '@project-osrm/osrm';
// import { RequestParamsTest, RequestParamsTestYears, YearlyResultTest } from './models/types';
// import { getTeaOutputs, processClustersForYear } from './processYear';
// dotenv.config();
// console.log('connecting to db', process.env.DB_HOST);
// // https://knexjs.org/
// const db = knex({
// client: 'pg',
// connection: {
// host: process.env.DB_HOST,
// user: process.env.DB_USER,
// password: process.env.DB_PASS,
// database: process.env.DB_NAME,
// port: Number(process.env.DB_PORT)
// }
// });
// console.log('connected to db. connected to osrm...');
// const osrm = new OSRM('./data/california-latest.osrm');
// console.log('connected to osrm');
// const test = async () => {
// console.log('test.....');
// const params: RequestParamsTestYears = {
// years: [2016],
// facilityLat: 39.644308,
// facilityLng: -121.553971,
// teaModel: 'GPO',
// teaInputs: {
// CapitalCost: 70000000,
// ElectricalFuelBaseYear: {
// NetElectricalCapacity: 25000,
// CapacityFactor: 85,
// MoistureContent: 50,
// NetStationEfficiency: 20,
// FuelHeatingValue: 18608,
// FuelAshConcentration: 5
// },
// ExpensesBaseYear: {
// BiomassFuelCost: 22.05,
// LaborCost: 2000000,
// MaintenanceCost: 1500000,
// InsurancePropertyTax: 1400000,
// Utilities: 200000,
// Management: 200000,
// OtherOperatingExpenses: 400000,
// AshDisposal: 100000
// },
// Taxes: { FederalTaxRate: 34, StateTaxRate: 9.6, ProductionTaxCredit: 0.009 },
// Financing: { DebtRatio: 75, InterestRateOnDebt: 5, EconomicLife: 20, CostOfEquity: 15 },
// IncomeOtherThanEnergy: {
// CapacityPayment: 166,
// InterestRateOnDebtReserve: 5,
// SalesPriceForChar: 0
// },
// EscalationInflation: {
// GeneralInflation: 2.1,
// EscalationBiomassFuel: 2.1,
// EscalationProductionTaxCredit: 2.1,
// EscalationHeatSales: 2.1,
// EscalationOther: 2.1,
// EscalationDualFuel: 2.1,
// EscalationCharSales: 2.1
// },
// TaxCreditFrac: [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
// },
// transmission: {
// VoltageClass: '230 kV Single Circuit',
// ConductorType: 'ACSS',
// Structure: 'Lattice',
// LengthCategory: '> 10 miles',
// NewOrReconductor: 'New',
// AverageTerrainMultiplier: 1,
// Miles: {
// Forested: 0,
// Flat: 1,
// Wetland: 0,
// Farmland: 0,
// Desert: 0,
// Urban: 0,
// Hills: 0,
// Mountain: 0,
// Zone1: 0,
// Zone2: 0,
// Zone3: 1,
// Zone4: 0,
// Zone5: 0,
// Zone6: 0,
// Zone7: 0,
// Zone8: 0,
// Zone9: 0,
// Zone10: 0,
// Zone11: 0,
// Zone12: 0
// }
// },
// };
// const systems = [
// 'Ground-Based Mech WT',
// 'Ground-Based Manual WT',
// 'Ground-Based Manual Log',
// 'Ground-Based CTL',
// 'Cable Manual WT/Log',
// 'Cable Manual WT',
// 'Cable Manual Log',
// 'Cable CTL',
// 'Helicopter Manual Log',
// 'Helicopter CTL'
// ];
// const treatments = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// const teaOutput: OutputModGPO | OutputModCHP | OutputModGP = await getTeaOutputs(
// params.teaModel,
// params.teaInputs
// );
// const biomassTarget = teaOutput.ElectricalAndFuelBaseYear.BiomassTarget;
// for (const treatment of treatments) {
// for (const system of systems) {
// console.log(`treatment: ${treatment}, system: ${system}`);
// }
// }
// console.log('done testing...');
// process.exit(0);
// };
// test();
// const testYears = async (
// treatmentid: number,
// system: string,
// teaModel: string,
// teaOutput: any,
// biomassTarget: number,
// params: RequestParamsTestYears
// ): Promise<YearlyResultTest> => {
// return new Promise(async (resolve, reject) => {
// // TODO: use separate TEA endpoint just to get biomass target
// // console.log(`biomassTarget: ${biomassTarget}, processing...`);
// try {
// const radius = 0;
// const paramsTest: RequestParamsTestYears = {
// ...params,
// treatmentid: treatmentid,
// system: system,
// teaModel: teaModel
// };
// const yearResult = await processClustersForYear(
// db,
// osrm,
// radius,
// paramsTest,
// teaOutput,
// biomassTarget,
// params.years[0],
// []
// );
// yearResult.lcaResults = undefined;
// // console.log(`year: ${result.year}, # of clusters: ${yearResult.clusterNumbers.length}`);
// // console.log(yearResult);
// const result: YearlyResultTest = {
// treatmentid: treatmentid,
// system: system,
// teaModel: teaModel,
// year: 2016,
// biomassTarget: yearResult.biomassTarget,
// totalBiomass: yearResult.totalBiomass,
// totalArea: yearResult.totalArea,
// totalResidueCost: yearResult.totalResidueCost,
// totalMoveInCost: yearResult.totalMoveInCost,
// totalMoveInDistance: yearResult.totalMoveInDistance,
// totalTransportationCost: yearResult.totalTransportationCost,
// numberOfClusters: yearResult.numberOfClusters,
// radius: yearResult.radius,
// data: JSON.stringify(yearResult)
// };
// console.log(`system: ${system}, treatment: ${treatmentid} resolving...`);
// resolve(result);
// } catch (e) {
// console.log('ERROR! ---------');
// console.log(e);
// reject(e);
// }
// });
// };