WWDC21 Swift Student Challenge Submission

Overview

CircuitPlay

Header

Introduction

Hello, welcome to Jose Adolfo Talactac's submission for WWDC21 Swift Student Challenge, CircuitPlay! CircuitPlay is an interactive sandbox experience that allows you to design, setup, and simulate circuit. CircuitPlay is written in Swift and built with SwiftUI, Accelerate, ARKit, and RealityKit. The showcase video can be found here.

User Interface

Existing circuit simulators on the market today have cluttered and outdated user interface. For students who are new to circuit theory, they may find these simulators daunting and overwhelming. CircuitPlay aims to fill the need for a simple and intuitive circuit simulator. CircuitPlay has a user interface with touch input in mind. The fluidity of its UI is thanks to versatility and power that SwiftUI provides.

CircuitPlay has three stages: Design, Setup, and Solve. In the Design stage, the user is presented with a grid and dock. The user can pick any component from the dock and drop it to a slot in the grid. Tapping a slot will show controls to rotate or delete the component. The Setup stage allows the user to change a component’s value by showing a popover prompt when the measurement is tapped.

Circuit Solving Algorithm

In the Solve stage, CircuitPlay uses its circuit solving algorithm. CircuitPlay first determines the nodes present in the circuit through recursion and matches the appropriate model for each circuit component. These nodes and models are the main parts of the circuit network.

Afterwards, CircuitPlay uses the modified nodal analysis (MNA) method, where the A matrix and b vector are formed. The A matrix describes the conductance between each node and the connections between voltage sources and each node. The b vector includes the known values, which are the current across nodes and the voltage sources values. Solving the x vector in Ax = b will provide the node voltages and the current across voltage sources.

The A matrix is sparse, meaning, there are zeroes that are present in the matrix. To leverage this, CircuitPlay utilizes Accelerate’s Sparse Solver framework to create a sparse matrix, and to factor and solve it. This is opposed to LAPACK which requires matrices to be dense. CircuitPlay only contains passive and time-domain components, thus, the matrix generated by CircuitPlay is also always symmetric. Memory use is reduced by only storing the upper triangle of the symmetric matrix. The appropriate factorization method for a symmetric and positive-indefinite matrix is the LDLᵀ decomposition. A direct method is utilized, meaning the matrix is only factored and solved once. Since there are no nonlinear components, such as diodes and transistors, it removes the need for an iterative method as there is no need to determine convergence with an I-V curve.

Using the SparseSolve methods, the node voltages and voltage source currents are solved. Using Current Divider Rule and Ohm’s Law, the voltage and current across different components are determined. For time-domain components like capacitors and inductors, a linearized companion model are utilized and backwards Euler’s method is performed to determine the equivalent values of the companion model at time step n+1.

Augmented Reality

CircuitPlay also provides an option to view the circuit in augmented reality. This AR portion is powered by ARKit and RealityKit. RealityKit allowed CircuitPlay to display 3D models with such high performance. It uses Focus Entity, an open-source Swift Package, to easily communicate surface detection to the user. Just like Jose Adolfo's WWDC2020 submission LearnWithAR, CircuitPlay further proves that augmented reality will have a significant role in the STEM education space in the future.

Credits

  • Barlow font designed by Jeremy Tribby found in the Playground thumbnail and the images in each PlaygroundPage is used under the Open Font License.
  • San Francisco font and SF Symbols icons found in the Playground’s interface is accessed as part of iPadOS’ system fonts and used fairly within the license set by Apple Inc. for the development of software for Apple platforms.
  • Focus Entity Swift Package by Max Cobb is used in the augmented reality component of the Playground for placing the model entity in the view. The package is used under the MIT license.
  • All assets that aren’t attributed to another party are made by the creator of this Playground, Jose Adolfo Talactac. These include the instructional text and images, 2D UI icons, and 3D USDZ models.

Screenshots

Screenshot 1 Screenshot 2 Screenshot 3 Screenshot 4 Screenshot 5

You might also like...
__.swift is a port of Underscore.js to Swift.

__.swift Now, __.swift is version 0.2.0! With the chain of methods, __.swift became more flexible and extensible. Documentation: http://lotz84.github.

SNTabBarDemo-Swift - Cool TabBar With Swift
SNTabBarDemo-Swift - Cool TabBar With Swift

SNTabBarDemo-Swift Cool TabBar How To Use // MARK: - setup private func setu

Swift-when - Expression switch support in Swift

Swift When - supporting switch expressions in Swift! What is it? Basically, it a

Swift-compute-runtime - Swift runtime for Fastly Compute@Edge

swift-compute-runtime Swift runtime for Fastly Compute@Edge Getting Started Crea

Swift-HorizontalPickerView - Customizable horizontal picker view component written in Swift for UIKit/iOS

Horizontal Picker View Customizable horizontal picker view component written in

swift-highlight a pure-Swift data structure library designed for server applications that need to store a lot of styled text

swift-highlight is a pure-Swift data structure library designed for server applications that need to store a lot of styled text. The Highlight module is memory-efficient and uses slab allocations and small-string optimizations to pack large amounts of styled text into a small amount of memory, while still supporting efficient traversal through the Sequence protocol.

Sovran-Swift: Small, efficient, easy. State Management for Swift

Sovran-Swift: Small, efficient, easy. State Management for Swift

Approximate is a Swift package that provides implementations of floating point comparisons for the Swift ecosystem

Approximate Approximate floating point equality comparisons for the Swift Programming Language. Introduction Approximate is a Swift package that provi

A Swift app, named 'iPose', for iPhone's pose measurement based on Swift.

iPhone's pose measurement based on Swift. This is a Swift app, named 'iPose', for iPhone's pose measurement based on Swift. This is a side project to

Owner
Jose Adolfo Talactac
Jose Adolfo Talactac
My Bootcamp ; 100 days challenge swift with swiftui

References : https://gelecegiyazanlar.turkcell.com.tr/konu/swift (free) https://gelecegiyazanlar.turkcell.com.tr/konu/swift-ile-ios-programlama (free)

burak cakir 3 Jun 5, 2022
iOS application for CA Tech Challenge ONLINE ACE created by @KS1019 and @techiro

インターン後改善したところ RepositoryのMock化を行って、ViewModelのテストを可能にした RepositoryやViewModelをコンストラクタインジェクションを使ってDI Repository自体のテストを実装できるように、URLSessionのAdapterを定義してスケジ

Kotaro Suto 1 Nov 25, 2021
Challenge... counting game for kids... should be entertaining, educational and fun... o_O

MultiTainment Simple multiplication game for kids. Possible to choose how many questions they want to answer and how hard shoud it be. Simple funny in

Pavel Surový 0 Dec 4, 2021
Pavel Surový 0 Jan 1, 2022
BCSwiftTor - Opinionated pure Swift controller for Tor, including full support for Swift 5.5 and Swift Concurrency

BCSwiftTor Opinionated pure Swift controller for Tor, including full support for

Blockchain Commons, LLC — A “not-for-profit” benefit corporation 4 Oct 6, 2022
Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Apple 2k Dec 28, 2022
Swift-DocC is a documentation compiler for Swift frameworks and packages aimed at making it easy to write and publish great developer documentation.

Swift-DocC is a documentation compiler for Swift frameworks and packages aimed at making it easy to write and publish great developer docum

Apple 833 Jan 3, 2023
Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux)

SwiftFoundation Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. Goals Provide a cross-platform in

null 620 Oct 11, 2022
Swift - ✏️Swift 공부 저장소✏️

Swift 스위프트의 기초 1. Swift의 기본 2. 변수와 상수 [3. 데이터 타입 기본] [4. 데이터 타입 고급] 5. 연산자 6. 흐름 제어 7. 함수 8. 옵셔널 객체지향 프로그래밍과 스위프트 9. 구조체와 클래스 10. 프로퍼티와 메서드 11. 인스턴스 생

Jiwon 0 Mar 9, 2022
Swift-ndi - Swift wrapper around NewTek's NDI SDK

swift-ndi Swift wrapper around NewTek's NDI SDK. Make sure you extracted latest

Alessio Nossa 12 Dec 29, 2022