public LinearSweep LinSweep(ScanDatabase _database) //Set the parameters for a linear sweep scan { LinearSweep linearSweep = new LinearSweep { BeginPotential = (float)_database.StartingPotential, EndPotential = (float)_database.EndingPotential, Scanrate = (float)_database.ScanRate, StepPotential = (float)_database.PotentialStep //Add in additional required values once determined }; return(linearSweep); }
//Below runs the necessary scan on the APM public async Task <Method> RunScan() { List <ScanDatabase> allDb = await App.Database.GetScanDatabasesAsync(); ScanDatabase _database = await App.Database.GetScanAsync(allDb.Count); ScanParams instance = new ScanParams(); switch (_database.VoltamType) { case "Linear Voltammetry": LinearSweep linSweep = instance.LinSweep(_database); linSweep.Ranging.StartCurrentRange = new CurrentRange(5); linSweep.Ranging.MaximumCurrentRange = new CurrentRange(6); linSweep.Ranging.MaximumCurrentRange = new CurrentRange(3); return(linSweep); case "Cyclic Voltammetry": CyclicVoltammetry cVoltammetry = instance.CV(_database); cVoltammetry.Ranging.StartCurrentRange = new CurrentRange(5); cVoltammetry.Ranging.MaximumCurrentRange = new CurrentRange(6); cVoltammetry.Ranging.MaximumCurrentRange = new CurrentRange(3); return(cVoltammetry); case "Square Wave Voltammetry": SquareWave squareWave = instance.SWV(_database); squareWave.Ranging.StartCurrentRange = new CurrentRange(5); squareWave.Ranging.MaximumCurrentRange = new CurrentRange(6); squareWave.Ranging.MaximumCurrentRange = new CurrentRange(3); return(squareWave); case "Alternating Current Voltammetry": ACVoltammetry acVoltammetry = instance.ACV(_database); acVoltammetry.Ranging.StartCurrentRange = new CurrentRange(5); acVoltammetry.Ranging.MaximumCurrentRange = new CurrentRange(6); acVoltammetry.Ranging.MaximumCurrentRange = new CurrentRange(3); return(acVoltammetry); default: //Add code to notify user that something has gone wrong and needs to be fixed return(null); } }
//Sets the scan parameters public async Task <Method> RunScan() { //Grabs the most recent database to get the required parameters List <ScanDatabase> allDb = await App.Database.GetScanDatabasesAsync(); ScanDatabase _database = await App.Database.GetScanAsync(allDb.Count); //Gets an instance of ScanParams ScanParams instance = new ScanParams(); switch (_database.VoltamType) //Switch which invokes the correct type of scan { case "Alternating Current Voltammetry": //Sets an alternating current voltammetric scan using (ACVoltammetry acVoltammetry = instance.ACV(_database)) { acVoltammetry.SmoothLevel = 0; acVoltammetry.Ranging.StartCurrentRange = new CurrentRange(CurrentRanges.cr10uA); //Sets the range that the potentiostat will use to detect the current acVoltammetry.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr100uA); acVoltammetry.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr100nA); return(acVoltammetry); } case "Cyclic Voltammetry": //Sets a cyclic voltammetric scan using (CyclicVoltammetry cVoltammetry = instance.CV(_database)) { cVoltammetry.SmoothLevel = 0; cVoltammetry.Ranging.StartCurrentRange = new CurrentRange(CurrentRanges.cr10uA); //Sets the range that the potentiostat will use to detect the current cVoltammetry.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr100uA); cVoltammetry.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr100nA); return(cVoltammetry); } case "Differential Pulse Voltammetry": //Sets a differential pulse voltammetric scan using (DifferentialPulse differentialPulse = instance.DPV(_database)) { differentialPulse.SmoothLevel = 0; differentialPulse.Ranging.StartCurrentRange = new CurrentRange(CurrentRanges.cr1uA); //Sets the range that the potentiostat will use to detect the current differentialPulse.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr1uA); differentialPulse.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr10nA); return(differentialPulse); } case "Linear Voltammetry": //Sets a linear voltammetric scan using (LinearSweep linSweep = instance.LinSweep(_database)) { linSweep.SmoothLevel = 0; linSweep.Ranging.StartCurrentRange = new CurrentRange(CurrentRanges.cr10uA); //Sets the range that the potentiostat will use to detect the current linSweep.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr100uA); linSweep.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr100nA); return(linSweep); } case "Square Wave Voltammetry": //Sets a square wave voltammetric scan using (SquareWave squareWave = instance.SWV(_database)) { squareWave.SmoothLevel = 0; squareWave.Ranging.StartCurrentRange = new CurrentRange(CurrentRanges.cr10uA); //Sets the range that the potentiostat will use to detect the current squareWave.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr100uA); squareWave.Ranging.MaximumCurrentRange = new CurrentRange(CurrentRanges.cr100nA); return(squareWave); } default: //Add code to notify user that something has gone wrong and needs to be fixed return(null); } }
private Noise CreateNoiseSimulation(string name, Control statement, ICircuitContext context) { Noise noise = null; // Check parameter count switch (statement.Parameters.Count) { case 0: context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, "SpiceModel expected for .NOISE", statement.LineInfo)); return(null); case 1: context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, "Source expected", statement.LineInfo)); return(null); case 2: context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, "Step type expected", statement.LineInfo)); return(null); case 3: context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, "Number of points expected", statement.LineInfo)); return(null); case 4: context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, "Starting frequency expected", statement.LineInfo)); return(null); case 5: context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, "Stopping frequency expected", statement.LineInfo)); return(null); case 6: break; case 7: break; default: context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, "Too many parameters for .NOISE", statement.LineInfo)); return(null); } string type = statement.Parameters.Get(2).Image; var numberSteps = context.Evaluator.EvaluateDouble(statement.Parameters.Get(3)); var start = context.Evaluator.EvaluateDouble(statement.Parameters.Get(4)); var stop = context.Evaluator.EvaluateDouble(statement.Parameters.Get(5)); Sweep <double> sweep; switch (type) { case "lin": sweep = new LinearSweep(start, stop, (int)numberSteps); break; case "oct": sweep = new OctaveSweep(start, stop, (int)numberSteps); break; case "dec": sweep = new DecadeSweep(start, stop, (int)numberSteps); break; default: context.Result.Validation.Add(new ValidationEntry(ValidationEntrySource.Reader, ValidationEntryLevel.Warning, "LIN, DEC or OCT expected", statement.LineInfo)); return(null); } // The first parameters needs to specify the output voltage if (statement.Parameters[0] is BracketParameter bracket) { if (bracket.Name.ToLower() == "v") { switch (bracket.Parameters.Count) { // V(A, B) - V(vector) // V(A) - V(singleParameter) case 1: if (bracket.Parameters[0] is VectorParameter v && v.Elements.Count == 2) { var output = v.Elements[0].Image; var reference = v.Elements[1].Image; var input = statement.Parameters[2].Image; noise = new Noise(name, output, reference, input, sweep); } else if (bracket.Parameters[0] is SingleParameter s) { var output = s.Image; var input = statement.Parameters[1].Image; noise = new Noise(name, output, input, sweep); } break;