This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def integrate(E, x_low, x_high, delta, V, plot=True): | |
def f(x): | |
return 2.0 * (V(x) - E) | |
delta_sq = delta ** 2 | |
N = int((x_high - x_low) / delta) | |
psi_left = 0.0 | |
# psi_right = 0.0 | |
psi_first = 1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infinite_well = { | |
"x_low": -1.0, | |
"x_high": 1.0, | |
"delta": 0.002, | |
"V": lambda x: 0.0 | |
} | |
psi = integrate(E=1.0, **infinite_well) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deviation(psi_computed, psi_actual): | |
return psi_computed - psi_actual | |
def find_energy_eigenstate(E_low, E_high, integration_params): | |
psi_right = 0.0 | |
psi_low = integrate(E_low, **integration_params) | |
psi_high = integrate(E_high, **integration_params) | |
dev_low = deviation(psi_low[-1], psi_right) | |
dev_high = deviation(psi_high[-1], psi_right) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct PieSliceView: View { | |
var body: some View { | |
Text("Hello, World!") | |
} | |
} | |
struct PieSliceData { | |
var startAngle: Angle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PieSliceView: View { | |
var pieSliceData: PieSliceData | |
var body: some View { | |
GeometryReader { geometry in | |
Path { path in | |
let width: CGFloat = min(geometry.size.width, geometry.size.height) | |
let height = width | |
let center = CGPoint(x: width * 0.5, y: height * 0.5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PieSliceView_Previews: PreviewProvider { | |
static var previews: some View { | |
PieSliceView(pieSliceData: PieSliceData( | |
startAngle: Angle(degrees: 0.0), | |
endAngle: Angle(degrees: 220.0), | |
color: Color.black)) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PieSliceView: View { | |
var pieSliceData: PieSliceData | |
var midRadians: Double { | |
return Double.pi / 2.0 - (pieSliceData.startAngle + pieSliceData.endAngle).radians / 2.0 | |
} | |
var body: some View { | |
GeometryReader { geometry in | |
ZStack { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct PieChartView: View { | |
public let values: [Double] | |
public var colors: [Color] | |
var slices: [PieSliceData] { | |
let sum = values.reduce(0, +) | |
var endDeg: Double = 0 | |
var tempSlices: [PieSliceData] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PieChartView: View { | |
public let values: [Double] | |
public var colors: [Color] | |
public var backgroundColor: Color | |
var slices: [PieSliceData] { | |
let sum = values.reduce(0, +) | |
var endDeg: Double = 0 | |
var tempSlices: [PieSliceData] = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var body: some View { | |
GeometryReader { geometry in | |
ZStack{ | |
ForEach(0..<self.values.count){ i in | |
PieSliceView(pieSliceData: self.slices[i]) | |
} | |
.frame(width: geometry.size.width, height: geometry.size.width) | |
Circle() | |
.fill(self.backgroundColor) |
OlderNewer