Answered step by step
Verified Expert Solution
Question
1 Approved Answer
fhis program will be written in the c + + language, and recap pointers, structures, and dyramic memory allacation. Create a program that will selve
fhis program will be written in the c language, and recap pointers, structures, and dyramic memory allacation.
Create a program that will selve for voltage and current across a capacitor as a function of time.
Constant current source power supply
For charging a capacitor with a constant current power supply, the resulting circuit looks ike
The current through a capacitor as a function of time can be written as
Using a finitedifference method, the voltage across the capacitor can be found as
At time the voltage across the capacitor is
Constant voltage seurce power supply
In this case, a resistor is used to protect the power supply. The resulting circuit loaks as
Insegrating equation and plugging inte equation with Chin's lae gipres
Taking die detivative of this equation and multiplying by yive:
:
At time is equal so
Data Format
Use a structure that looks like
:
typodef struct capacitor Gabstah
Solve for the voltage across the capacitor in the constant current case using
In words, this means that the voltage at the next time step is equal to the voltage and the previous time step t
plus the current at the previous timestep t multiplied by and inverse capacitance.
and the current through the capacitor using
Again, in words, this means that the current at the next timestep is equal to the current at the previous timestep
minus the current at the previous timestep multiplied by resistance, capacitance and
Again in words, this means that the cursent at the neat tirestap is equal so the current at the previous timestep
t minus the curnent at the previous timestep t multipied by resistance. capocitance and
Uie the valuet of
hinal time se
Number of timatereps ie hfie scovos
tanis
A for conetant current suaply
V for conctant woltage sapply
You will need to dyanmicaly allocute the tinse, woltsge, and cartert arrays in the structure, Output the fosulting
current and voltage for the capacitor for the diffenent changing circuits exry timestops to the screen.
A loop over the number of timesteps will be feeded to iterate the voltage ard current is time, Start at timestep
with timestep o being filled with the initial conditions given in the equation detalls.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started