sciforge-hub 0.0.4

Central hub orchestrating Sciforge subsystems (api, engine, tools).
Documentation
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
//! Dispatch handler for plant biology functions.

use super::super::params::*;
use crate::domain::biology as bio;
use crate::domain::common::errors::{HubError, HubResult};
use crate::engine::experience::runner::RunOutput;

pub(super) fn dispatch(func: &str, p: &Params) -> HubResult<RunOutput> {
    match func {
        "competitive_exclusion_tilman" => Ok(RunOutput::Text(
            bio::plant_biology::ecology::competitive_exclusion_tilman(
                get_f(p, "r_star_a")?,
                get_f(p, "r_star_b")?,
            )
            .to_string(),
        )),
        "allelopathy_effect" => Ok(RunOutput::Scalar(
            bio::plant_biology::ecology::allelopathy_effect(
                get_f(p, "allelochemical_conc")?,
                get_f(p, "ic50")?,
                get_f(p, "max_inhibition")?,
            ),
        )),
        "light_competition_beer_lambert" => Ok(RunOutput::Scalar(
            bio::plant_biology::ecology::light_competition_beer_lambert(
                get_f(p, "light_above")?,
                get_f(p, "lai")?,
                get_f(p, "extinction_coeff")?,
            ),
        )),
        "canopy_lai" => Ok(RunOutput::Scalar(bio::plant_biology::ecology::canopy_lai(
            get_f(p, "leaf_area")?,
            get_f(p, "ground_area")?,
        ))),
        "sla" => Ok(RunOutput::Scalar(bio::plant_biology::ecology::sla(
            get_f(p, "leaf_area")?,
            get_f(p, "leaf_dry_mass")?,
        ))),
        "plant_defense_investment" => Ok(RunOutput::Scalar(
            bio::plant_biology::ecology::plant_defense_investment(
                get_f(p, "growth_rate")?,
                get_f(p, "defense_allocation")?,
            ),
        )),
        "herbivory_damage" => Ok(RunOutput::Scalar(
            bio::plant_biology::ecology::herbivory_damage(
                get_f(p, "herbivore_density")?,
                get_f(p, "feeding_rate")?,
                get_f(p, "plant_biomass")?,
                get_f(p, "defense_level")?,
            ),
        )),
        "seed_dispersal_kernel" => Ok(RunOutput::Scalar(
            bio::plant_biology::ecology::seed_dispersal_kernel(
                get_f(p, "distance")?,
                get_f(p, "mean_dispersal")?,
            ),
        )),
        "pollination_success" => Ok(RunOutput::Scalar(
            bio::plant_biology::ecology::pollination_success(
                get_f(p, "pollinator_visits")?,
                get_f(p, "pollen_per_visit")?,
                get_f(p, "ovule_count")?,
            ),
        )),
        "nitrogen_fixation_symbiotic" => Ok(RunOutput::Scalar(
            bio::plant_biology::ecology::nitrogen_fixation_symbiotic(
                get_f(p, "nodule_mass")?,
                get_f(p, "nitrogenase_activity")?,
                get_f(p, "oxygen_limitation")?,
            ),
        )),
        "root_growth_logistic" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::root_growth_logistic(
                get_f(p, "length")?,
                get_f(p, "max_length")?,
                get_f(p, "rate")?,
                get_f(p, "dt")?,
            ),
        )),
        "auxin_gradient" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::auxin_gradient(
                get_f(p, "source_concentration")?,
                get_f(p, "distance")?,
                get_f(p, "diffusion")?,
                get_f(p, "decay")?,
            ),
        )),
        "phototropism_bending_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::phototropism_bending_rate(
                get_f(p, "light_differential")?,
                get_f(p, "sensitivity")?,
            ),
        )),
        "gravitropism_response" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::gravitropism_response(
                get_f(p, "angle")?,
                get_f(p, "sensitivity")?,
                get_f(p, "dt")?,
            ),
        )),
        "leaf_area_index" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::leaf_area_index(
                get_f(p, "total_leaf_area")?,
                get_f(p, "ground_area")?,
            ),
        )),
        "beer_lambert_canopy" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::beer_lambert_canopy(
                get_f(p, "light_above")?,
                get_f(p, "k")?,
                get_f(p, "lai")?,
            ),
        )),
        "thermal_time" => Ok(RunOutput::Scalar(bio::plant_biology::growth::thermal_time(
            get_f(p, "daily_mean_temp")?,
            get_f(p, "base_temp")?,
        ))),
        "water_potential" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::water_potential(
                get_f(p, "osmotic")?,
                get_f(p, "pressure")?,
                get_f(p, "gravitational")?,
            ),
        )),
        "xylem_flow_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::xylem_flow_rate(
                get_f(p, "pressure_gradient")?,
                get_f(p, "conductivity")?,
                get_f(p, "cross_section")?,
            ),
        )),
        "phloem_transport_munch" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::phloem_transport_munch(
                get_f(p, "source_pressure")?,
                get_f(p, "sink_pressure")?,
                get_f(p, "resistance")?,
            ),
        )),
        "allometric_biomass" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::allometric_biomass(
                get_f(p, "diameter")?,
                get_f(p, "a")?,
                get_f(p, "b")?,
            ),
        )),
        "specific_leaf_area" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::specific_leaf_area(
                get_f(p, "leaf_area")?,
                get_f(p, "leaf_dry_mass")?,
            ),
        )),
        "relative_growth_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::relative_growth_rate(
                get_f(p, "biomass_initial")?,
                get_f(p, "biomass_final")?,
                get_f(p, "time")?,
            ),
        )),
        "net_assimilation_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::net_assimilation_rate(
                get_f(p, "biomass_change")?,
                get_f(p, "leaf_area_avg")?,
                get_f(p, "time")?,
            ),
        )),
        "phytochrome_response" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::phytochrome_response(
                get_f(p, "red")?,
                get_f(p, "far_red")?,
            ),
        )),
        "vernalization_progress" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::vernalization_progress(
                get_f(p, "temp")?,
                get_f(p, "optimal_temp")?,
                get_f(p, "range")?,
                get_f(p, "dt")?,
            ),
        )),
        "photoperiod_response" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::photoperiod_response(
                get_f(p, "day_length")?,
                get_f(p, "critical_length")?,
                get_f(p, "sensitivity")?,
            ),
        )),
        "root_shoot_ratio" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::root_shoot_ratio(
                get_f(p, "root_biomass")?,
                get_f(p, "shoot_biomass")?,
            ),
        )),
        "canopy_gap_fraction" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::canopy_gap_fraction(get_f(p, "lai")?, get_f(p, "k")?),
        )),
        "stem_taper" => Ok(RunOutput::Scalar(bio::plant_biology::growth::stem_taper(
            get_f(p, "diameter_base")?,
            get_f(p, "height_fraction")?,
            get_f(p, "taper_exponent")?,
        ))),
        "cavitation_vulnerability" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::cavitation_vulnerability(
                get_f(p, "pressure")?,
                get_f(p, "p50")?,
                get_f(p, "slope")?,
            ),
        )),
        "turgor_pressure" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::turgor_pressure(
                get_f(p, "osmotic_potential")?,
                get_f(p, "water_potential")?,
            ),
        )),
        "gibberellin_stem_elongation" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::gibberellin_stem_elongation(
                get_f(p, "ga_concentration")?,
                get_f(p, "max_rate")?,
                get_f(p, "km")?,
            ),
        )),
        "senescence_chlorophyll_loss" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::senescence_chlorophyll_loss(
                get_f(p, "chl0")?,
                get_f(p, "degradation_rate")?,
                get_f(p, "t")?,
            ),
        )),
        "frost_hardiness" => Ok(RunOutput::Scalar(
            bio::plant_biology::growth::frost_hardiness(
                get_f(p, "temp")?,
                get_f(p, "lt50")?,
                get_f(p, "slope")?,
            ),
        )),
        "farquhar_c3" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::farquhar_c3(
                get_f(p, "vcmax")?,
                get_f(p, "ci")?,
                get_f(p, "gamma_star")?,
                get_f(p, "kc")?,
                get_f(p, "ko")?,
                get_f(p, "o")?,
                get_f(p, "j")?,
                get_f(p, "rd")?,
            ),
        )),
        "plant_light_response_curve" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::light_response_curve(
                get_f(p, "phi")?,
                get_f(p, "ppfd")?,
                get_f(p, "amax")?,
                get_f(p, "theta")?,
                get_f(p, "rd")?,
            ),
        )),
        "transpiration_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::transpiration_rate(
                get_f(p, "stomatal_conductance")?,
                get_f(p, "vpd")?,
            ),
        )),
        "ball_berry_conductance" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::ball_berry_conductance(
                get_f(p, "a_n")?,
                get_f(p, "cs")?,
                get_f(p, "rh")?,
                get_f(p, "g0")?,
                get_f(p, "g1")?,
            ),
        )),
        "plant_water_use_efficiency" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::water_use_efficiency(
                get_f(p, "a_n")?,
                get_f(p, "transpiration")?,
            ),
        )),
        "penman_monteith" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::penman_monteith(
                get_f(p, "net_radiation")?,
                get_f(p, "soil_heat")?,
                get_f(p, "vpd")?,
                get_f(p, "ga")?,
                get_f(p, "gs")?,
                get_f(p, "delta")?,
                get_f(p, "gamma")?,
                get_f(p, "rho")?,
                get_f(p, "cp")?,
            ),
        )),
        "plant_rubisco_specificity" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::rubisco_specificity(
                get_f(p, "vcmax")?,
                get_f(p, "kc")?,
                get_f(p, "vomax")?,
                get_f(p, "ko")?,
            ),
        )),
        "plant_photorespiration_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::photorespiration_rate(
                get_f(p, "vomax")?,
                get_f(p, "o")?,
                get_f(p, "ko")?,
                get_f(p, "ci")?,
                get_f(p, "kc")?,
            ),
        )),
        "plant_electron_transport_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::electron_transport_rate(
                get_f(p, "ppfd")?,
                get_f(p, "absorptance")?,
                get_f(p, "fraction_psii")?,
                get_f(p, "phi_psii")?,
            ),
        )),
        "stomatal_optimization" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::stomatal_optimization(
                get_f(p, "vpd")?,
                get_f(p, "ca")?,
                get_f(p, "lambda_wue")?,
                get_f(p, "g1")?,
            ),
        )),
        "c4_photosynthesis" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::c4_photosynthesis(
                get_f(p, "vpmax")?,
                get_f(p, "ci")?,
                get_f(p, "kp")?,
                get_f(p, "vcmax")?,
                get_f(p, "ko")?,
                get_f(p, "kc")?,
                get_f(p, "o")?,
                get_f(p, "rd")?,
            ),
        )),
        "cam_malic_acid_storage" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::cam_malic_acid_storage(
                get_f(p, "co2_fixed_night")?,
                get_f(p, "vacuole_capacity")?,
                get_f(p, "current_malate")?,
            ),
        )),
        "cam_daytime_decarboxylation" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::cam_daytime_decarboxylation(
                get_f(p, "malate")?,
                get_f(p, "decarboxylation_rate")?,
            ),
        )),
        "chlorophyll_fluorescence_fv_fm" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::chlorophyll_fluorescence_fv_fm(
                get_f(p, "f0")?,
                get_f(p, "fm")?,
            ),
        )),
        "non_photochemical_quenching" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::non_photochemical_quenching(
                get_f(p, "fm")?,
                get_f(p, "fm_prime")?,
            ),
        )),
        "photochemical_quenching" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::photochemical_quenching(
                get_f(p, "fs")?,
                get_f(p, "f0_prime")?,
                get_f(p, "fm_prime")?,
            ),
        )),
        "quantum_yield_psii" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::quantum_yield_psii(
                get_f(p, "phi_psii")?,
                get_f(p, "ppfd")?,
            ),
        )),
        "co2_compensation_point" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::co2_compensation_point(
                get_f(p, "gamma_star")?,
                get_f(p, "rd")?,
                get_f(p, "vcmax")?,
                get_f(p, "kc")?,
                get_f(p, "ko")?,
                get_f(p, "o")?,
            ),
        )),
        "mesophyll_conductance" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::mesophyll_conductance(
                get_f(p, "a_n")?,
                get_f(p, "ci")?,
                get_f(p, "cc")?,
            ),
        )),
        "light_use_efficiency" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::light_use_efficiency(
                get_f(p, "gpp")?,
                get_f(p, "apar")?,
            ),
        )),
        "vcmax_temperature_response" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::vcmax_temperature_response(
                get_f(p, "vcmax25")?,
                get_f(p, "ha")?,
                get_f(p, "temp_k")?,
            ),
        )),
        "jmax_temperature_peaked" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::jmax_temperature_peaked(
                get_f(p, "jmax25")?,
                get_f(p, "ha")?,
                get_f(p, "hd")?,
                get_f(p, "ds")?,
                get_f(p, "temp_k")?,
            ),
        )),
        "xylem_flow_hagen_poiseuille" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::xylem_flow_hagen_poiseuille(
                get_f(p, "radius")?,
                get_f(p, "pressure_gradient")?,
                get_f(p, "viscosity")?,
                get_f(p, "length")?,
            ),
        )),
        "leaf_transpiration_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::leaf_transpiration_rate(
                get_f(p, "stomatal_conductance")?,
                get_f(p, "vpd")?,
            ),
        )),
        "cohesion_tension_water_potential" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::cohesion_tension_water_potential(
                get_f(p, "osmotic")?,
                get_f(p, "pressure")?,
                get_f(p, "gravity")?,
                get_f(p, "matric")?,
            ),
        )),
        "phloem_munch_flow" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::phloem_munch_flow(
                get_f(p, "turgor_source")?,
                get_f(p, "turgor_sink")?,
                get_f(p, "resistance")?,
            ),
        )),
        "root_water_uptake" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::root_water_uptake(
                get_f(p, "soil_water_potential")?,
                get_f(p, "root_water_potential")?,
                get_f(p, "root_conductance")?,
            ),
        )),
        "xylem_cavitation_vulnerability" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::xylem_cavitation_vulnerability(
                get_f(p, "water_potential")?,
                get_f(p, "p50")?,
                get_f(p, "slope")?,
            ),
        )),
        "plant_stomatal_conductance_ball_berry" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::stomatal_conductance_ball_berry(
                get_f(p, "assimilation")?,
                get_f(p, "humidity")?,
                get_f(p, "co2_surface")?,
                get_f(p, "g0")?,
                get_f(p, "g1")?,
            ),
        )),
        "sugar_loading_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::sugar_loading_rate(
                get_f(p, "sucrose_conc")?,
                get_f(p, "vmax")?,
                get_f(p, "km")?,
            ),
        )),
        "root_hydraulic_conductivity" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::root_hydraulic_conductivity(
                get_f(p, "flow_rate")?,
                get_f(p, "root_surface_area")?,
                get_f(p, "pressure_difference")?,
            ),
        )),
        "sap_flow_heat_pulse" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::sap_flow_heat_pulse(
                get_f(p, "thermal_diffusivity")?,
                get_f(p, "heat_pulse_distance")?,
                get_f(p, "time_to_max")?,
            ),
        )),
        "electron_transport_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::electron_transport_rate(
                get_f(p, "ppfd")?,
                get_f(p, "absorptance")?,
                get_f(p, "fraction_psii")?,
                get_f(p, "phi_psii")?,
            ),
        )),
        "light_response_curve" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::light_response_curve(
                get_f(p, "phi")?,
                get_f(p, "ppfd")?,
                get_f(p, "amax")?,
                get_f(p, "theta")?,
                get_f(p, "rd")?,
            ),
        )),
        "photorespiration_rate" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::photorespiration_rate(
                get_f(p, "vomax")?,
                get_f(p, "o")?,
                get_f(p, "ko")?,
                get_f(p, "ci")?,
                get_f(p, "kc")?,
            ),
        )),
        "rubisco_specificity" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::rubisco_specificity(
                get_f(p, "vcmax")?,
                get_f(p, "kc")?,
                get_f(p, "vomax")?,
                get_f(p, "ko")?,
            ),
        )),
        "stomatal_conductance_ball_berry" => Ok(RunOutput::Scalar(
            bio::plant_biology::transport::stomatal_conductance_ball_berry(
                get_f(p, "assimilation")?,
                get_f(p, "humidity")?,
                get_f(p, "co2_surface")?,
                get_f(p, "g0")?,
                get_f(p, "g1")?,
            ),
        )),
        "water_use_efficiency" => Ok(RunOutput::Scalar(
            bio::plant_biology::photosynthesis::water_use_efficiency(
                get_f(p, "a_n")?,
                get_f(p, "transpiration")?,
            ),
        )),
        _ => Err(HubError::InvalidInput(format!("unknown function: {func}"))),
    }
}