turbo-sim / turboflow

Meanline model for performance prediction and preliminary design of turbomachinery
MIT License
11 stars 1 forks source link

Implement JAX automatic differentiation on Turboflow #11

Closed RoberAgro closed 1 day ago

RoberAgro commented 1 month ago
SrinivasDiwanji commented 2 weeks ago

Verified the gradients for all the cascade functions and also for evaluate_axial_turbine

Educated guess still required to get meaningful derivative values for comparison

SrinivasDiwanji commented 2 weeks ago

Pandas dataframe usage has been removed in performance analysis. It has been replaced by dictionaries and other functions decribed in numerics and file_utils docs

SrinivasDiwanji commented 2 weeks ago

Writing and storing the results gives errors as it uses pandas commands. This has to be updated and changed.

SrinivasDiwanji commented 2 weeks ago

Jax works with isentropic and critical mach choking criteira for the complete axial turbine problem

SrinivasDiwanji commented 2 weeks ago

The issue is with critical mass flow rate choking criteria for which jax is not working. Jax differentiates compute_critical_values function in choking criteria but Jax fails when differentiating critical_mass_flow_rate function

SrinivasDiwanji commented 2 weeks ago

Jax runs for whole turbine calculation with critical_mach_number and kacker-okapuu loss model

SrinivasDiwanji commented 2 weeks ago

Jax runs for whole turbine calculation with critical_mach_number and moustapha loss model

SrinivasDiwanji commented 1 week ago

Now JAX runs for whole turbine calculation with critical_mach_number and all loss models

SrinivasDiwanji commented 1 week ago

JAX works for two_stage turbine calculation too with crtical_mach_number as choking criterion and all loss models. Now the issue is with critical_mass_flow_rate choking criterion, it has a tracing error with JAX. One possible issue is with how the function is defined. Checking the issue

SrinivasDiwanji commented 1 week ago

JAX works now with critical_mass_flow_rate choking criterion too. The tracer error was due to the fact that critical_state was initialized within the critical_mass_flow_rate function and it was being updated which caused the tracer error while using JAX. It is resolved by using another dict updated_critical_state to avoid mutation of critical_state. The updated code works now

SrinivasDiwanji commented 1 week ago

Performance analysis differentiation with JAX has been done

SrinivasDiwanji commented 1 week ago

Design Optimization works with critical mach number and approx derivatives

SrinivasDiwanji commented 1 week ago

Some probable issues with design_optimization:

  1. In evaluate_constraints a jax array is initialized and then being updated which can cause a problem
  2. Similar in-place modifications are being done in fitness_gradient_based for geometry, equality constraints array which can cause a problem
  3. Strings stator and rotor cannot form a part of jax array and can cause a problem
SrinivasDiwanji commented 1 week ago

len() doesn't work with jax array