Skip to content

Commit

Permalink
sharding for steady manoeuvre added
Browse files Browse the repository at this point in the history
  • Loading branch information
ACea15 committed Nov 6, 2024
1 parent e50692d commit 8072eab
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 55 deletions.
29 changes: 25 additions & 4 deletions docs/schemas/draft1.org
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,17 @@ derivatives

* System based solutions
TODO: make automatic label as the first
| Type | Target | Gravity | BC1 | ModalAero | SteadyAero | UnsteadyAero | Point loads | q0 approx | Rigid-body | Nonlinearities | residualised |
|-------------+--------+------------+------------+-----------+--------------+--------------+-------------+-----------+----------------------+------------------------+--------------|
| 1 static | Level | False: "g" | Clamped | None | None | None | None | via q2 | 1-quaternion+strains | All -> "" | None -> "" |
| 2 Dynamic | TRIM1 | True: "G" | Free | Rogers | qalpha | gust | follower | via q1 | All-quaternions | Linear sys -> "l" | True -> "r" |
| Type | Target | Gravity | BC1 | ModalAero | SteadyAero | UnsteadyAero | Point loads | q0 approx | Rigid-body | Nonlinearities | residualised |
|--------------+--------+------------+------------+-----------+--------------+--------------+-------------+-----------+----------------------+------------------------+--------------|
| 1 static | Level | False: "g" | Clamped | None | None | None | None | via q2 | 1-quaternion+strains | All -> "" | None -> "" |
| 2 Dynamic | TRIM1 | True: "G" | Free | Rogers | qalpha | gust | follower | via q1 | All-quaternions | Linear sys -> "l" | True -> "r" |
| 3 staticAD | | | | | | | | | | | |
| 4 dynamicAD | | | | | | | | | | | |
| 3 staticPL | TRIM2 | | Prescribed | Loewner | qx (control) | controls | dead | | | Linear sys+disp -> "L" | |
| 3 dynamicPL | TRIM2 | | Prescribed | Loewner | qx (control) | controls | dead | | | Linear sys+disp -> "L" | |
| 3 staticPLAD | TRIM2 | | Prescribed | Loewner | qx (control) | controls | dead | | | Linear sys+disp -> "L" | |
| 3 | TRIM2 | | Prescribed | Loewner | qx (control) | controls | dead | | | Linear sys+disp -> "L" | |

| 3 Stability | TRIM2 | | Prescribed | Loewner | qx (control) | controls | dead | | | Linear sys+disp -> "L" | |
| 4 Multibody | | | | | | | | | | | |
| 5 Control | | | | | | | | | | | |
Expand Down Expand Up @@ -738,6 +745,20 @@ Well in place for Nastran Models except for the derivatives provided by Nastran
Extensive work carried out into a software architecture that complies with good design principles.
#+RESULTS: classes_architecture2
[[file:classes2.png]]


** Systems

Static and dynamic systems for static and dynamic simulations

Systems with labels:


[[file:~/projects/FENIAX/feniax/systems/intrinsic_system.py::label = f"dq_{self.settings.label}"][intrinsic_system]]
[[file:~/projects/FENIAX/feniax/systems/intrinsicAD.py::label = f"main_{label_sys}_{label_ad}"][AD_system]]
[[file:~/projects/FENIAX/feniax/systems/intrinsicShard.py::self.label = f"main_{label_sys}_{label_shard}"][shard_system]]


* Short term goals
- Set up a testing framework with well-known problems in nonlinear structural-mechanics/aeroelasticity.
- Application to the Bristol model provided by Airbus.
Expand Down
2 changes: 2 additions & 0 deletions examples/BUG/Streamlit/pages/1_Geometry.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
import feniax.plotools.streamlit.pages.Geometry
import importlib
importlib.reload(feniax.plotools.streamlit.pages.Geometry)
24 changes: 24 additions & 0 deletions feniax/intrinsic/argshard.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,27 @@ def arg_10g11(
C0ab = sol.data.modes.C0ab

return (phi2l, psi2l, X_xdelta, C0ab, (eta_0, gamma2, omega, phi1l, x,))

def arg_10g15(
sol: solution.IntrinsicSolution,
system: intrinsicmodal.Dsystem,
fem: intrinsicmodal.Dfem,
*args,
**kwargs,
):

eta_0 = kwargs["eta_0"]
gamma2 = sol.data.couplings.gamma2
phi1l = sol.data.modes.phi1l
phi2l = sol.data.modes.phi2l
psi2l = sol.data.modes.psi2l
X_xdelta = sol.data.modes.X_xdelta
omega = sol.data.modes.omega
x = system.xloads.x
X_xdelta = sol.data.modes.X_xdelta
C0ab = sol.data.modes.C0ab
qalpha = system.aero.qalpha
A0 = system.aero.A[0]
C0 = system.aero.Q0_rigid

return (phi2l, psi2l, X_xdelta, C0ab, A0, C0, (eta_0, gamma2, omega, x, qalpha))
31 changes: 11 additions & 20 deletions feniax/intrinsic/staticShard.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,8 @@ def _main_10g11_1(inp):
results = main_vmap(inputs)
return results

def dq_10g15(q, *args):
"""Manoeuvre under qalpha."""

(eta_0, gamma2, omega, x, qalpha, A0hat, C0hat, t) = args[0]
q0 = -q / omega
F = omega * q - common.contraction_gamma2(gamma2, q)
F += xloads.eta_steadyaero(q0, A0hat)
F += xloads.eta_manoeuvre(t, x, qalpha, C0hat)
F += eta_0
return F

@partial(jax.jit, static_argnames=["config"])
def main_10g15_1(
def main_10g15_2(
inputs, #
q0,
config,
Expand All @@ -72,22 +61,24 @@ def main_10g15_1(
tn = len(t_loads)
q2_index = config.system.states["q2"]
X = config.fem.X
phi2l, psi2l, X_xdelta, C0ab, _dqargs = args

phi2l, psi2l, X_xdelta, C0ab, A0, C0, _dqargs = args
# @jax.jit
def _main_10g11_1(inp):

dq_args = _dqargs + (inp,)
def _main_10g15_2(inp):

q_inf = 0.5 * inp[0] * inp[1]**2
A0hat = A0 * q_inf
C0hat = C0* q_inf
dq_args = _dqargs + (A0hat, C0hat)
q = _solve(
newton, dq_static.dq_10g11, t_loads, q0, dq_args, config.system.solver_settings
newton, dq_static.dq_10g15, t_loads, q0, dq_args, config.system.solver_settings
)
q2 = q[:, q2_index]
#jax.debug.breakpoint()
X2, X3, ra, Cab = isys.recover_staticfields(
q2, tn, X, phi2l, psi2l, X_xdelta, C0ab, config
)
return dict(q=q, X2=X2, X3=X3, ra=ra, Cab=Cab)

main_vmap = jax.vmap(_main_10g11_1)
main_vmap = jax.vmap(_main_10g15_2)
results = main_vmap(inputs)
return results
32 changes: 30 additions & 2 deletions feniax/intrinsic/xloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ def _mapgravity(points_gravity, points_gravity_vect):

return shardforce_gravity #Ns_Nx_6_Nn

def shard_gust(inputs: intrinsicmodal.DShard_gust1) -> jnp.ndarray:

def shard_gust1(inputs: intrinsicmodal.DShard_gust1) -> jnp.ndarray:

prod_list = []
for k, v in inputs.__dict__.items():
Expand All @@ -357,6 +358,21 @@ def shard_gust(inputs: intrinsicmodal.DShard_gust1) -> jnp.ndarray:
prod = list(itertools.product(*prod_list))
return jnp.array(prod)

def shard_steadyalpha(inputs: intrinsicmodal.DShard_steadyalpha,
default: intrinsicmodal.Daero) -> jnp.ndarray:

prod_list = []
default_dict = default.__dict__
for k, v in inputs.__dict__.items():
if v is not None:
prod_list.append(v)
elif k == "aeromatrix":
prod_list.append([0])
else:
d_k = default_dict[k]
prod_list.append([d_k])
prod = list(itertools.product(*prod_list))
return jnp.array(prod)



Expand All @@ -383,5 +399,17 @@ def shard_gust(inputs: intrinsicmodal.DShard_gust1) -> jnp.ndarray:
print((dead1 == shard_dead[1]).all())

g1 = intrinsicmodal.DShard_gust1(length=[10,20],intensity=[3,4,5], u_inf=[100,150], rho_inf=[0.2,0.3,0.6])
prod = shard_gust(g1)
prod = shard_gust1(g1)
print(prod)

steadyalpha = intrinsicmodal.DShard_steadyalpha(u_inf=[100,150], rho_inf=[0.2,0.3,0.6])
aero = intrinsicmodal.Daero(u_inf=100, rho_inf=0.4)
prod = shard_steadyalpha(steadyalpha, aero)
print(prod)

print("-----------")
steadyalpha = intrinsicmodal.DShard_steadyalpha(u_inf=[100,150])
aero = intrinsicmodal.Daero(u_inf=100, rho_inf=0.4)
prod = shard_steadyalpha(steadyalpha, aero)
print(prod)

19 changes: 18 additions & 1 deletion feniax/preprocessor/containers/intrinsicmodal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ def __post_init__(self):

class ShardinputType(Enum):
POINTFORCES = 1
STEADYALPHA = 2
GUST1 = 3


Expand Down Expand Up @@ -1077,7 +1078,23 @@ def __post_init__(self):
if self.gravity_vect is not None:
object.__setattr__(self, "gravity_vect", jnp.array(self.gravity_vect))
self._initialize_attributes()


@Ddataclass
class DShard_steadyalpha(DataContainer):
"""Point forces
Parameters
----------
"""

rho_inf: jnp.ndarray = dfield("", default=None)
u_inf: jnp.ndarray = dfield("", default=None)
aeromatrix: list[int] = dfield("", default=None)
def __post_init__(self):

self._initialize_attributes()

@Ddataclass
class DShard_gust1(DataContainer):
"""Point forces
Expand Down
3 changes: 3 additions & 0 deletions feniax/preprocessor/containers/intrinsicsol.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ class GustRoger:
Qhj_wsum: jnp.ndarray = None
Qhjl_wdot: jnp.ndarray = None

@dataclass(slots=True)
class Shards:
points: jnp.ndarray = None



Expand Down
77 changes: 49 additions & 28 deletions feniax/systems/intrinsicShard.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,47 @@ def set_args(self):
solver_args = getattr(argshard, f"arg_{label}")
self.args1 = solver_args(self.sol, self.settings, self.fem, eta_0=self.eta0)


def set_xloading(self):
def _set_gust1(self):

super().set_xloading()
self.xpoints = xloads.shard_gust1(self.settings.shard.inputs)

def _set_pointforces(self):

num_nodes = self.fem.num_nodes
C06ab = self.sol.data.modes.C06ab
if self.settings.shard.input_type.lower() == "pointforces":
if self.settings.shard.inputs.follower_points is not None:
super().set_xloading(compute_follower=False)
self.xpoints = xloads.shard_point_follower(self.settings.xloads.x,
self.settings.shard.inputs.follower_points,
self.settings.shard.inputs.follower_interpolation,
num_nodes,
C06ab)
elif self.settings.shard.inputs.dead_points is not None:
super().set_xloading(compute_dead=False)
self.xpoints = xloads.shard_point_dead(self.settings.xloads.x,
self.settings.shard.inputs.dead_points,
self.settings.shard.inputs.dead_interpolation,
num_nodes)
elif self.settings.shard.inputs.gravity is not None:
super().set_xloading(compute_gravity=False)
self.xpoints = xloads.shard_gravity(self.settings.xloads.x,
self.settings.shard.inputs.gravity,
self.settings.shard.inputs.gravity_vect,
self.fem.Ma,
self.fem.Mfe_order)

elif self.settings.shard.input_type.lower() == "gust1":
super().set_xloading()
self.xpoints = xloads.shard_gust(self.settings.shard.inputs)
C06ab = self.sol.data.modes.C06ab
if self.settings.shard.inputs.follower_points is not None:
super().set_xloading(compute_follower=False)
self.xpoints = xloads.shard_point_follower(self.settings.xloads.x,
self.settings.shard.inputs.follower_points,
self.settings.shard.inputs.follower_interpolation,
num_nodes,
C06ab)
elif self.settings.shard.inputs.dead_points is not None:
super().set_xloading(compute_dead=False)
self.xpoints = xloads.shard_point_dead(self.settings.xloads.x,
self.settings.shard.inputs.dead_points,
self.settings.shard.inputs.dead_interpolation,
num_nodes)
elif self.settings.shard.inputs.gravity is not None:
super().set_xloading(compute_gravity=False)
self.xpoints = xloads.shard_gravity(self.settings.xloads.x,
self.settings.shard.inputs.gravity,
self.settings.shard.inputs.gravity_vect,
self.fem.Ma,
self.fem.Mfe_order)

def _set_steadyalpha(self):

super().set_xloading()
self.xpoints = xloads.shard_steadyalpha(self.settings.shard.inputs,
self.settings.aero)

def set_xloading(self):

shard_type = self.settings.shard.input_type.lower()
f_shard = getattr(self, f"_set_{shard_type}")
f_shard()

def solve(self):

Expand All @@ -67,6 +77,15 @@ def solve(self):

self.build_solution(**results)

def build_solution(self):
self.sol.add_container(
"Shards",
label="_" + self.name,
points=self.xpoints,
)
if self.settings.save:
self.sol.save_container("Shards", label="_" + self.name)

class StaticShardIntrinsic(IntrinsicShardSystem, cls_name="staticShard_intrinsic"):

def set_system(self):
Expand All @@ -78,6 +97,7 @@ def set_system(self):

def build_solution(self, q, X2, X3, ra, Cab, *args, **kwargs):

super().build_solution()
self.sol.add_container(
"StaticSystem",
label="_" + self.name,
Expand All @@ -104,6 +124,7 @@ def set_system(self):

def build_solution(self, q, X1, X2, X3, ra, Cab, *args, **kwargs):

super().build_solution()
self.sol.add_container(
"DynamicSystem",
label="_" + self.name,
Expand Down

0 comments on commit 8072eab

Please sign in to comment.