Skip to content

Commit

Permalink
Return Vy_n_DB_array and K_n_DB_array (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzkW35 authored Oct 15, 2023
2 parents 593c985 + b94e6cb commit 274debf
Show file tree
Hide file tree
Showing 12 changed files with 532 additions and 657 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/fly-deploy-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Fly Deploy Test App
on:
pull_request:
branches:
- staging
paths:
- "src/**"
workflow_dispatch:

jobs:
deploy:
name: Deploy test app
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: flyctl deploy --remote-only -c fly_test.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN_TEST }}
7 changes: 0 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ on:
push:
branches:
- 'main'
- 'staging'
pull_request:
branches:
- 'main'
- 'staging'
tags:
- "v*"
workflow_dispatch:

env:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ on:
push:
paths:
- "src/**"
pull_request:
branches:
- "main"
- "staging"
- "tests/**"
workflow_dispatch:

jobs:
Expand Down
35 changes: 2 additions & 33 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,36 +1,5 @@
.. These are examples of badges you might want to add to your README:
please update the URLs accordingly
.. image:: https://api.cirrus-ci.com/github/<USER>/AIDApp.svg?branch=main
:alt: Built Status
:target: https://cirrus-ci.com/github/<USER>/AIDApp
.. image:: https://readthedocs.org/projects/AIDApp/badge/?version=latest
:alt: ReadTheDocs
:target: https://AIDApp.readthedocs.io/en/stable/
.. image:: https://img.shields.io/coveralls/github/<USER>/AIDApp/main.svg
:alt: Coveralls
:target: https://coveralls.io/r/<USER>/AIDApp
.. image:: https://img.shields.io/pypi/v/AIDApp.svg
:alt: PyPI-Server
:target: https://pypi.org/project/AIDApp/
.. image:: https://img.shields.io/conda/vn/conda-forge/AIDApp.svg
:alt: Conda-Forge
:target: https://anaconda.org/conda-forge/AIDApp
.. image:: https://pepy.tech/badge/AIDApp/month
:alt: Monthly Downloads
:target: https://pepy.tech/project/AIDApp
.. image:: https://img.shields.io/twitter/url/http/shields.io.svg?style=social&label=Twitter
:alt: Twitter
:target: https://twitter.com/AIDApp
======
AIDApp
AIDApp-core
======


Desktop app to design patented anti-seismic devices




.. _pyscaffold-notes:
Backend of AIDApp, the webapp to design patented anti-seismic devices.
2 changes: 0 additions & 2 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
app = "aidapp-core"
primary_region = "cdg"

[build]

[http_service]
internal_port = 8080
force_https = true
Expand Down
15 changes: 15 additions & 0 deletions fly_test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# fly.toml app configuration file generated for aidapp-core on 2023-10-11T19:55:47+02:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "aidapp-core-test"
primary_region = "cdg"

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]
11 changes: 3 additions & 8 deletions src/aidapp/api/schemas/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ class InputValues(BaseModel):
kf: float
storey_masses: List[float]
eigenvalues: List[float]
brace_number: List[int]
zonation_0: List[float]
zonation_1: List[float]
zonation_2: List[float]
zonation_ag: List[float]
zonation_fo: List[float]
zonation_tc: List[float]
pushover_x: List[float]
pushover_y: List[float]
span_length: float
interfloor_height: float
nominal_age: int
functional_class: str
topographic_factor: str
Expand All @@ -31,8 +28,6 @@ class InputValues(BaseModel):
class OutputValues(BaseModel):
"""Output value model for the AIDAPP calculate endpoint."""

kc_n_s_array: List[float]
Fc_n_s_array: List[float]
i: int
x_bilinear: List[float]
y_bilinear_ms2: List[float]
Expand Down
68 changes: 6 additions & 62 deletions src/aidapp/calcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,7 @@

import logging

from numpy import (
absolute,
arctan,
array,
cov,
cumsum,
diagflat,
hypot,
matmul,
pi,
trapz,
)
from numpy import absolute, array, cov, cumsum, diagflat, matmul, pi, trapz

from aidapp.coordinates import Coords
from aidapp.utils import rd
Expand Down Expand Up @@ -42,7 +31,6 @@ def __init__(self):
self.Vy_DB_array = None
self.dy_n_array = None
self.dy_n_array = None
self.K_n_DB_array = None

@staticmethod
def convert_to_meters(coord_mm):
Expand Down Expand Up @@ -295,58 +283,14 @@ def get_K_storey_n_array(self):
return K_storey_n_array

# Frame data
@staticmethod
def get_upwind_lenght(span_length, interfloor_height):
"""Calculate the lenght of the upwind."""
return rd(hypot((span_length), (interfloor_height)))

@staticmethod
def get_slope(span_length, interfloor_height):
"""Calculate the slope of the upwind."""
return rd(arctan(interfloor_height / span_length))

@staticmethod
def cos_alpha(span_length, upwind_lenght):
"""Calculate the cos(alpha) of the upwind."""
return rd(span_length / upwind_lenght)

def get_K_n_DB_array(self, span_length, interfloor_height):
def get_K_n_DB_array(self):
"""Calculate the values of K_n(DB)."""
upwind_lenght = self.get_upwind_lenght(span_length, interfloor_height)
self.K_n_DB_array = rd(
self.Vy_DB_array
/ (self.dy_n_array * array(self.cos_alpha(span_length, upwind_lenght) ** 2))
)
return self.K_n_DB_array
K_n_DB_array = rd(self.Vy_DB_array / self.dy_n_array)
return K_n_DB_array

def get_Ny_n_DB_array(self, span_length, interfloor_height):
def get_Ny_n_DB_array(self):
"""Calculate the values of Ny(DB)."""
Ny_n_DB_array = []
upwind_lenght = self.get_upwind_lenght(span_length, interfloor_height)
for element in self.Vy_DB_array:
Ny_n_DB = rd((element) / self.cos_alpha(span_length, upwind_lenght))
Ny_n_DB_array.append(Ny_n_DB)
return Ny_n_DB_array

def get_kc_n_s_array(self, brace_number):
"""Calculate the values of the brace rigidity for each floor (kc_n_s)."""
kc_n_s_array = []
k = 0
for element in self.K_n_DB_array:
kc_n_s = rd((element) / brace_number[0 + k])
k = k + 1
kc_n_s_array.append(kc_n_s)
return kc_n_s_array

def get_Fc_n_s_array(self, brace_number, span_length, interfloor_height):
"""Calculate the values of the brace force for each floor (Fc_n_s)."""
Fc_n_s_array = []
k = 0
for element in self.get_Ny_n_DB_array(span_length, interfloor_height):
Fc_n_s = rd(element / brace_number[0 + k])
k = k + 1
Fc_n_s_array.append(Fc_n_s)
return Fc_n_s_array
return self.Vy_DB_array


class Area:
Expand Down
26 changes: 9 additions & 17 deletions src/aidapp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def main(input_values):
eigenvalues = rd(input_values.eigenvalues)
pushover_x = rd(input_values.pushover_x)
pushover_y = rd(input_values.pushover_y)
ag_input = rd(input_values.zonation_0)
fo_input = rd(input_values.zonation_1)
tc_input = rd(input_values.zonation_2)
ag_input = rd(input_values.zonation_ag)
fo_input = rd(input_values.zonation_fo)
tc_input = rd(input_values.zonation_tc)

gamma = values.get_gamma(storey_masses, eigenvalues)
dp = rd(input_values.dp / gamma) # [m]
Expand Down Expand Up @@ -189,24 +189,16 @@ def get_calcs_recursive(Vp_DB, check, i, Vy_F_DB, Vp_F_DB, kn_eff, de_n):
values.get_Vy_DB_final(Vp_DB)
values.get_Fy_n_DB_array()
values.get_dy_DB_final(input_values.mu_DB, dp)
values.get_Vy_n_DB_array().tolist()
Vy_n_DB_array = values.get_Vy_n_DB_array()
values.get_dy_n_array(eigenvalues)
values.get_K_storey_n_array().tolist()
values.get_K_n_DB_array(
input_values.span_length, input_values.interfloor_height
)
kc_n_s_array = values.get_kc_n_s_array(input_values.brace_number)
Fc_n_s_array = values.get_Fc_n_s_array(
input_values.brace_number,
input_values.span_length,
input_values.interfloor_height,
)
K_n_DB_array = values.get_K_n_DB_array()

OutputValues = namedtuple(
"OutputValues",
[
"kc_n_s_array",
"Fc_n_s_array",
"Vy_n_DB_array",
"K_n_DB_array",
"i",
"x_bilinear",
"y_bilinear_ms2",
Expand All @@ -222,8 +214,8 @@ def get_calcs_recursive(Vp_DB, check, i, Vy_F_DB, Vp_F_DB, kn_eff, de_n):
)

return OutputValues(
kc_n_s_array,
Fc_n_s_array,
Vy_n_DB_array.tolist(),
K_n_DB_array.tolist(),
i,
x_bilinear.tolist(),
y_bilinear_ms2.tolist(),
Expand Down
25 changes: 3 additions & 22 deletions tests/test_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,6 @@ def test_calculate_endpoint_valid_input():
response = client.post("/calculate/", json=payload)
assert response.status_code == 200

assert response.json()["kc_n_s_array"] == [
896060.0409196536,
461111.24652382464,
342785.6925901348,
331648.53775286616,
324788.7688801968,
253737.4026480032,
]
assert response.json()["Fc_n_s_array"] == [
852.868455309155,
821.586663019117,
734.840773590922,
585.588377513482,
382.303200328156,
142.997493643942,
]
assert response.json()["i"] == 5
assert response.json()["de_0"] == [0.148465762254, 4.838711036209]
assert response.json()["de_n"] == [0.092350797764, 7.807520454074]
Expand All @@ -51,14 +35,11 @@ def test_calculate_endpoint_invalid_input():
231.4220183,
],
eigenvalues=[0.113530691, 0.326058618],
brace_number=[2, 2],
zonation_0=[0.1, "invalid"],
zonation_1=[0.1, 0.2],
zonation_2=[0.1, 0.2],
zonation_ag=[0.1, "invalid"],
zonation_fo=[0.1, 0.2],
zonation_tc=[0.1, 0.2],
pushover_x=[0, 0.0015, 0.003, 0.0045],
pushover_y=[0, 55.59392236, 109.3670878, 163.8144485],
span_length=6,
interfloor_height=3,
nominal_age=50,
functional_class="I",
topographic_factor="T1",
Expand Down
Loading

0 comments on commit 274debf

Please sign in to comment.