Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catheter aq #20

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Catheter aq #20

wants to merge 4 commits into from

Conversation

ibenemerito88
Copy link
Collaborator

Extension of openBF for studying the effects of arterial catheters on the blood flow in elastic vessels. The equations have been updated (modification to flux and its gradient, source term, wave speed, Riemann invariants), as well as the conditions for junction, bifucation and anastomosis.

Windkessel boundary conditions are not supported, reflections are.

Tests for junctions and bifurcations have been included but need to be improved. Test for anastomosis is still missing.

catheterAQ.pdf

Manifest.toml
*.sh
*.swp
Copy link
Collaborator

@alemelis alemelis Jan 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qui conviene aggiungere anche tutti i .last e .out così da non averli anche nella PR, insieme a tutta la cartella backupres

openBF.solveModel(vessels, edges, blood, dt, current_time)
openBF.updateGhostCells(vessels)
current_time += dt
plot(vessels[1].u)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anche questo file forse si può eliminare dalla PR

@@ -46,19 +46,20 @@ end
Return the Jacobian for anastomosis equations.
"""
function calculateJacobianAnastomosis(v1 :: Vessel, v2 :: Vessel, v3 :: Vessel, U, k)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qui, ma anche nelle funzioni successive, per qualche motivo che non ricordo non ho specificato il tipo di U e k, ma andrebbe fatto. A occhio mi sembrano due Array{Float,1}

@@ -46,19 +46,20 @@ end
Return the Jacobian for anastomosis equations.
"""
function calculateJacobianAnastomosis(v1 :: Vessel, v2 :: Vessel, v3 :: Vessel, U, k)
@fastmath @inbounds g1 = sqrt(1-v1.Ac/U[4]^4) # MODIFIED THIS LINE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qui puoi usare U43 e calcolare g1 come

g1 = sqrt(1.0 - v1.Ac / (U43*U[4]))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ovviamente g va definita dopo U

Copy link
Collaborator

@alemelis alemelis Jan 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intendo dire che le linee da 49 a 54 vanno riorganizzate come

U43 = U[4]*U[4]*U[4]
g1 = sqrt(1.0 - v1.Ac / (U43*U[4]))
U53 = U[5]*U[5]*U[5]
g2 = sqrt(1.0 - v2.Ac/ (U53*U[5]))
U63 = U[6]*U[6]*U[6]
g3 = sqrt(1.0 - v3.Ac/U63*U[6])

@fastmath @inbounds J41 = U[4]*U43
@fastmath @inbounds J42 = U[5]*U53
@fastmath @inbounds J43 = -U[6]*U63
@fastmath @inbounds J41 = U[4]*U43 - v1.Ac # MODIFIED THIS LINE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e dato che qui si ricalcola U[4]*U43, conviene definire una variabile U44 per questo valore in modo da calcolarla una volta sola

v1 = vessels[1] # MODIFIED THIS LINE
v2 = vessels[2] # MODIFIED THIS LINE
v3 = vessels[3] # MODIFIED THIS LINE
@fastmath @inbounds g1 = sqrt(1-v1.Ac/U[4]^4) # MODIFIED THIS LINE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in generale * é più veloce di ^, quindi puoi riscrivere come v1.Ac/(U[4]*U[4]*U[4]*U[4])

in generale se usi direttamente 1.0 invece di 1, eviti la conversione durante l'esecuzione

gamma_profile = vessel_data["gamma_profile"]
else
gamma_profile = 9
end
return 2*(gamma_profile + 2)*pi*blood.mu*blood.rho_inv
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

questo dovrebbe andare dopo l'end, altrimenti non restituisce quello che vuoi tu nel caso il secondo if sia verificato

"""
function waveSpeed(A :: Float64, gamma :: Float64)
return sqrt(3*gamma*sqrt(A)*0.5)
function waveSpeed(A :: Float64, gamma :: Float64, Ac :: Float64)
Copy link
Collaborator

@alemelis alemelis Jan 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cambiando la definizione di questa funzione alcuni test non passano:

LoadError: MethodError: no method matching waveSpeed(::Float64, ::Float64)
  Closest candidates are:
    waveSpeed(::Float64, ::Float64, !Matched::Float64)

per semplificare, puoi dare a Ac un valore di default (direi 0.0) che viene usato nel caso in cui la funzione sia chiamata senza quell'argomento

function waveSpeed(A::Float64, gamma::Float64, Ac::Float64 = 0.0)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oppure cambi i test aggiungendo Ac nella chiamata

end
return 2*(gamma_profile + 2)*pi*blood.mu*blood.rho_inv

end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibenemerito88 occhio che il return e' sempre dentro l'ultimo else (in teoria julia dovrebbe essere abbastanza intelligente da fare il return di gamma_profile anche per linea 591...ma non mi affiderei troppo a queste proprieta' esoteriche del linguaggio)

function computeViscousTerm(vessel_data :: Dict{Any,Any}, blood :: Blood)
    if haskey(vessel_data,"Rc")                     # MODIFIED THIS LINE
        return 2*blood.mu*blood.rho_inv*sqrt(30)
    elseif haskey(vessel_data, "gamma_profile")
        gamma_profile = vessel_data["gamma_profile"]
    else
        gamma_profile = 9
    end
    return 2*(gamma_profile + 2)*blood.mu*blood.rho_inv
end

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(sicuri che pi non ci vada? tutta la validazione della tesi e' stata fatta in quel modo)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants