source: branches/collapse/surrogate.py @ 855

Revision 855, 2.1 KB checked in by mmckerns, 5 months ago (diff)

updated copyright to 2016

Line 
1#!/usr/bin/env python
2#
3# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4# Copyright (c) 2009-2016 California Institute of Technology.
5# License: 3-clause BSD.  The full license text is available at:
6#  - http://mmckerns.github.io/project/mystic/browser/mystic/LICENSE
7
8"""Original matlab code:
9
10function A=marc_surr(x)
11h=x(1)*25.4*10^(-3);
12a=x(2)*pi/180;
13v=x(3);
14Ho=0.5794;
15s=1.4004;
16n=0.4482;
17K=10.3963;
18p=0.4757;
19u=1.0275;
20m=0.4682;
21Dp=1.778;
22
23v_bl=Ho*(h/(cos(a))^(n))^s;
24
25if v<v_bl
26  A=0
27else
28  A=K*((h/Dp)^p)*((cos(a))^u)*(tanh((v/v_bl)-1))^m;
29end
30"""
31
32### NOTES ###
33# h = thickness = [60,105]
34# a = obliquity = [0,30]
35# v = speed = [2.1,2.8]
36
37# explore the cuboid (h,a,v), with
38# subdivisions at h=100, a=20, v=2.2
39# due to ballistic limit: v(h=100,a=20) = 2.22,
40# perforation in this region should be zero.
41# NOTE: 'failure' is A < = t
42#
43# Calculate for each of the 8 subcuboids:
44#  * probability mass, i.e. the product of the normalized side-lengths,
45#    since we're taking h, a and v to be uniformly distributed in their
46#    intervals
47#  * McDiarmid diameter of the perforation area A when restricted to that
48#    cuboid or subcuboid
49#  * the mean value of the perforation area A on each (sub)cuboid
50
51from math import pi, cos, tanh
52
53def ballistic_limit(h,a):
54  """calculate ballistic limit
55
56  Inputs:
57    - h = thickness in (unknown) units
58    - a = obliquity in (unknown) units
59
60  Outputs:
61    - v_bl = velocity (ballistic limit) in (unknown) units
62"""
63 #h = x[0] * 25.4 * 1e-3
64 #a = x[1] * pi/180.0
65  Ho = 0.5794
66  s = 1.4004
67  n = 0.4482
68  return Ho * ( h / cos(a)**n )**s
69
70
71def marc_surr(x):
72  """calculate perforation area using a tanh-based model surrogate
73
74  Inputs:
75    - x = [thickness, obliquity, speed] in (unknown) units
76
77  Outputs:
78    - A = performation area in (unknown) units
79"""
80# h = thickness = [60,105]
81# a = obliquity = [0,30]
82# v = speed = [2.1,2.8]
83  h = x[0] * 25.4 * 1e-3
84  a = x[1] * pi/180.0
85  v = x[2]
86
87  K = 10.3963
88  p = 0.4757
89  u = 1.0275
90  m = 0.4682
91  Dp = 1.778
92
93  # compare to ballistic limit
94  v_bl = ballistic_limit(h,a)
95  if v < v_bl:
96    return 0
97
98  return K * (h/Dp)**p * (cos(a))**u * (tanh((v/v_bl)-1))**m
99
100# EOF
Note: See TracBrowser for help on using the repository browser.